Description
The behavior of this (and possibly other logic) seems to have regressed in 2.12.0 compared to 2.11.0. As documented in the Javadoc "Also, as from v1.3 this method creates parent directories if they do not exist." (see here) but this no longer works, instead it uses PathUtils.touch which does not have the capability of creating the parent dirs.
e.g
@Test public void doTouch() throws Exception { FileUtils.touch(new File("doesnt-exist", "touchme.txt")); }
doesnt-exist/touchme.txt
java.nio.file.NoSuchFileException: doesnt-exist/touchme.txt
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
at java.base/java.nio.file.Files.newByteChannel(Files.java:380)
at java.base/java.nio.file.Files.createFile(Files.java:658)
at org.apache.commons.io.file.PathUtils.touch(PathUtils.java:1613)
at org.apache.commons.io.FileUtils.touch(FileUtils.java:3090)
Appears to have regressed in https://github.com/apache/commons-io/commit/fd7c8182d2117d01f43ccc9fe939105f834ba672 - PathUtils relies on java.nio.Files.createFile which explicitly does not have ability to create parent directories.