I am trying to create some data files with date & time in the file name on Windows. The file name is like "C:/data-2018-11-07 11:02:42.log". However when I tried the folowing code:
File file = new File("C:/data-2018-11-07 11:02:42.log").getCanonicalFile();
An Exception come out:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
at java.io.File.getCanonicalPath(File.java:618)
at java.io.File.getCanonicalFile(File.java:643)
How can I remove this exception? I tried with replacing the ":" with "_", it worked good. What I can do to use the ":"?
And I was using Java 8.