public void writeRow( RowMetaInterface rowMeta, Object[] r ) throws KettleStepException {
    try {
      if ( Utils.isEmpty( meta.getOutputFields() ) ) {
        /*
         * Write all values in stream to text file.
         */
        for ( int i = 0; i < rowMeta.size(); i++ ) {
          if ( i > 0 && data.binarySeparator.length > 0 ) {
            data.writer.write( data.binarySeparator );
          }
          ValueMetaInterface v = rowMeta.getValueMeta( i );
          Object valueData = r[i];

          // no special null value default was specified since no fields are specified at all
          // As such, we pass null
          //
          writeField( v, valueData, null );
        }
      } else {
        /*
         * Only write the fields specified!
         */
        for ( int i = 0; i < meta.getOutputFields().length; i++ ) {
          if ( i > 0 && data.binarySeparator.length > 0 ) {
            data.writer.write( data.binarySeparator );
          }

          ValueMetaInterface v = meta.getMetaWithFieldOptions()[ i ];
          Object valueData = r[ data.fieldnrs[ i ] ];
          writeField( v, valueData, data.binaryNullValue[ i ] );
        }
      }

      data.writer.write( data.binaryNewline );

      incrementLinesOutput();

    } catch ( Exception e ) {
      throw new KettleStepException( "Error writing line", e );
    }
  }
@Test
  public void testFastDumpDisableStreamEncodeTest() throws Exception {

    textFileOutput =
      new TextFileOutputTestHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0,
        stepMockHelper.transMeta,
        stepMockHelper.trans );
    textFileOutput.meta = stepMockHelper.processRowsStepMetaInterface;

    String testString = "ÖÜä";
    String inputEncode = StandardCharsets.UTF_8.name();
    String outputEncode = StandardCharsets.ISO_8859_1.name();
    Object[] rows = { testString.getBytes( inputEncode ) };

    ValueMetaBase valueMetaInterface = new ValueMetaBase( "test", ValueMetaInterface.TYPE_STRING );
    valueMetaInterface.setStringEncoding( inputEncode );
    valueMetaInterface.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING );
    valueMetaInterface.setStorageMetadata( new ValueMetaString() );

    TextFileOutputData data = new TextFileOutputData();
    data.binarySeparator = " ".getBytes();
    data.binaryEnclosure = "\"".getBytes();
    data.binaryNewline = "\n".getBytes();
    textFileOutput.data = data;

    RowMeta rowMeta = new RowMeta();
    rowMeta.addValueMeta( valueMetaInterface );

    doReturn( outputEncode ).when( stepMockHelper.processRowsStepMetaInterface ).getEncoding();
    textFileOutput.data.writer = mock( BufferedOutputStream.class );

    textFileOutput.writeRow( rowMeta, rows );
    verify( textFileOutput.data.writer ).write( testString.getBytes( outputEncode ) );
  }