Windows treats libraries differently from regular folders and paths. Thus when I use this block of code to create a text file:
File filePath = fc.getSelectedFile();
… More irrelevant stuff…
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();
}
It works if the file is in, say, the Desktop folder, but if I try to put it in the My Pictures Library, I get this error message:
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)
Is there a way for me to fix this?
Looks like a bug, tested and confirmed on my system as well with java 7 update4 32bit.
Exception:
An ugly workaround could be to specify a file filter that filters out those, see:
Selecting 'Computer' or 'Libraries' in Java's JFileChooser yields a strange File object