{"record":{"id":"e02534dc89bbde22","repo":"pentaho/pentaho-kettle","slug":"changefileencoding-error-creatingfile","errorCode":"ChangeFileEncoding.Error.CreatingFile","errorMessage":"ChangeFileEncoding.Error.CreatingFile","messagePattern":"ChangeFileEncoding\\.Error\\.CreatingFile","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java","lineNumber":243,"sourceCode":"        }\n      }\n      // add filename to result filenames?\n      if ( meta.addTargetResultFilenames() ) {\n        // Add this to the result file names...\n        ResultFile resultFile =\n            new ResultFile( ResultFile.FILE_TYPE_GENERAL,\n                KettleVFS.getInstance( getTransMeta().getBowl() ).getFileObject( targetFilename ),\n                getTransMeta().getName(), getStepname() );\n        resultFile.setComment( BaseMessages.getString( PKG, \"ChangeFileEncoding.Log.FileAddedResult\" ) );\n        addResultFile( resultFile );\n\n        if ( isDetailed() ) {\n          logDetailed( BaseMessages.getString( PKG, \"ChangeFileEncoding.Log.FilenameAddResult\", targetFilename ) );\n        }\n      }\n\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"ChangeFileEncoding.Error.CreatingFile\" ), e );\n    } finally {\n      try {\n        if ( buffWriter != null ) {\n          buffWriter.flush();\n          buffWriter.close();\n        }\n        if ( buffReader != null ) {\n          buffReader.close();\n        }\n      } catch ( Exception e ) {\n        // Ignore\n      }\n    }\n\n  }\n\n  public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {\n    meta = (ChangeFileEncodingMeta) smi;","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/changefileencoding/ChangeFileEncoding.java#L225-L261","documentation":"Generic wrapper: any exception thrown while changeEncoding() reads the source stream and writes the re-encoded target file (open, read, write, or charset conversion failures) is caught and rethrown as a KettleException with the CreatingFile message, chaining the original cause. The real reason is always in the nested exception.","triggerScenarios":"In changeEncoding's try block: KettleVFS file creation/open of the target, reader/writer construction with unsupported charset names, IOExceptions during copy, or target file access problems — all funnel into this catch-all.","commonSituations":"Invalid encoding name typed in the dialog (e.g. 'utf8' vs 'UTF-8'); target file locked by another process; disk full; permission denied writing to target directory; source file being read while another step truncates it.","solutions":["Inspect the chained cause exception in the log to find the underlying IO/charset error.","Validate encoding names against java.nio.charset.Charset.isSupported(name) (use 'UTF-8', 'ISO-8859-1', etc.).","Check write permissions on the target directory and free disk space.","Close other processes holding the target file open."],"exampleFix":"// before\nString encoding = \"utf8\";\n// after\nString encoding = Charset.isSupported( \"utf8\" ) ? \"utf8\" : \"UTF-8\"; // use canonical 'UTF-8'","handlingStrategy":"try-catch","validationCode":"// validate encodings before running\nimport java.nio.charset.Charset;\nif ( !Charset.isSupported( sourceEncoding ) || !Charset.isSupported( targetEncoding ) ) {\n  throw new IllegalArgumentException( \"Unsupported charset\" );\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute( null );\n} catch ( KettleException e ) {\n  // CreatingFile wraps the real cause — inspect the chain\n  Throwable cause = e.getCause();\n  log.error( \"Encoding conversion failed: {}\", cause == null ? e : cause );\n}","preventionTips":["Use canonical charset names (\"UTF-8\", not \"utf8\").","Monitor disk space and target-directory permissions in deployment environments.","Avoid concurrent steps writing to the same target file."],"tags":["etl","kettle","file-write","io"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}