有谁知道Java如何能够规避Windows MAX_PATH限制。使用下面的代码,我能够在Java中创建一个非常长的路径,并且能够执行I/O,而使用不带前缀\\?\的窗口是不可能的。Java如何规避Windows MAX_PATH WinAPI限制
public static void main(String[] args) throws IOException {
BufferedWriter bufWriter = null;
try {
StringBuilder s = new StringBuilder();
for (int i = 0; i < 130; i++) {
s.append("asdf\\");
}
String filePath = "C:\\" + s.toString();;
System.out.println("File Path = " + filePath);
File f = new File(filePath);
f.mkdirs();
f = new File(f, "dummy.txt");
System.out.println("Full path = " + f);
bufWriter = new BufferedWriter(new FileWriter(f));
bufWriter.write("Hello");
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (bufWriter != null) {
bufWriter.close();
}
}
}
您使用的是哪个版本的Windows? – 2012-04-10 18:32:38
我正在使用Windows 7 ... – Rajiv 2012-04-10 18:38:02