[ https://issues.apache.org/jira/browse/IO-620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16906244#comment-16906244 ]
Sebb commented on IO-620: ------------------------- Try with resources is supposed to close the file. Is that not happening? > FileUtils.writeStringToFile does not close() stream > --------------------------------------------------- > > Key: IO-620 > URL: https://issues.apache.org/jira/browse/IO-620 > Project: Commons IO > Issue Type: Bug > Components: Streams/Writers > Affects Versions: 2.6 > Reporter: Eric Long > Priority: Major > > FileUtils.writeStringToFile() method does not close the OutputStream. This > can lead to running out of file descriptors, inability to write to the file a > second time (Windows), and unpredictable file contents (Unix). > public static void writeStringToFile(final File file, final String data, > final Charset encoding, > final boolean append) throws > IOException { > try (OutputStream out = openOutputStream(file, append)) { > IOUtils.write(data, out, encoding); > } > } > > The stream is closed in version 2.5, but not in 2.6. It may have been > introduced on the following commit: > https://github.com/apache/commons-io/commit/4dc97b64005f0083b2facaa70f661138a4fa3fc0#diff-5999114d4c52063bbe7063696cf20215 -- This message was sent by Atlassian JIRA (v7.6.14#76016)