Windows 以不同于常规文件夹和路径的方式处理库。因此,当我使用这段代码创建一个文本文件时:
File filePath = fc.getSelectedFile();
...更多无关紧要的东西...
File outputText = new File(filePath.getParentFile(), "Decrypted.txt");
try
{
FileWriter fw = new FileWriter(outputText); //Write everything to the file.
fw.write(messageOut);
fw.close(); //DON'T FORGET TO CLOSE THE FILE!
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
如果文件在桌面文件夹中,它可以工作,但是如果我尝试将它放在我的图片库中,我会收到以下错误消息:
java.io.FileNotFoundException: ::{031E4825-7B94-4DC3-B131-E946B44C8DD5}\Pictures.library-ms\Decrypted.txt (The system cannot find the path specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at code.Crypto.decrypt(Crypto.java:57)
at code.Crypto.main(Crypto.java:27)
我有办法解决这个问题吗?