0
我使用一個簡單的Java程序來獲取文件的規範路徑,File.getCanonicalPath無法處理NTFS流?
import java.io.*;
public class Foo {
public static void main (String[] args)
{
try {
File file = new File(args[0]);
System.out.println(file.getCanonicalPath());
} catch (Exception e) {
e.printStackTrace();
}
}
}
當涉及到NTFS流,它會引發異常
C:\>java Foo c:\windows\system32\calc.exe::$DATA
java.io.IOException: The filename, directory name, or volume label syntax is inc
orrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at Foo.main(Foo.java:8)
任何想法?
別使用** :: $ DATA **代替使用 java -jar Foo.jar「C:\ Users \ SamDev \ Documents \ NetBeansProjects \ MyThreads \ dist \ README.txt」$ DATA – 2017-10-10 10:28:03