using: New Java 7 NIO library, try
if(!Files.exists(filePath.getParent())) { Files.createDirectory(filePath.getParent()); } if(!Files.exists(filePath)) { Files.createFile(filePath); }
The above code checks if Directoty exists, if it does not create a directory, checks if the file exists, yes, it writes an empty line and clears the buffer, at the end you get a writer that points to an empty file
harsha Aug 26 '18 at 9:33 2018-08-26 09:33
source share