Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2200203 | 6u23 | Vladislav Karnaukhov | P3 | Resolved | Fixed | b02 |
JDK-2199461 | 6u22-rev | Vladislav Karnaukhov | P3 | Closed | Fixed | b05 |
JDK-2189716 | 6u21-rev | Vladislav Karnaukhov | P3 | Closed | Fixed | b11 |
FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
File.canWrite() returns false for the user's "My Documents" directory, when specified as the path "c:\documents and settings\<username>\my documents".
This is incorrect as the "My Documents" directory is writable.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the test program below. When the Swing file chooser appears, navigate to your "My Documents" directory via
c:\documents and settings\<your username>\my documents
Click OK. The debug output will indicate that this directory is not writable.
Some subdirectories under "My Documents" are writable - here's some sample output:
$ javac Foo.java && java Foo
** Not writable **: C:\Documents and Settings\johnc\My Documents
Writable: C:\Documents and Settings\johnc\My Documents\Visual Studio Projects
Writable: H:
Note, this is not a Swing problem, as the same happens when creating a File object for "c:\documents and settings\johnc\my documents" and calling canWrite() on that.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
canWrite() should return true for the "My Documents" directory.
ACTUAL -
canWrite() returns false for the "My Documents" directory.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.filechooser.*;
import java.awt.*;
import java.io.File;
public class Foo extends JFrame {
public static void main(String[] args) {
JFrame frame = new JFrame();
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileHidingEnabled(false);
while (true) {
int option = chooser.showDialog(frame, "OK");
if (option != JFileChooser.APPROVE_OPTION)
continue;
File file = chooser.getSelectedFile();
// try {
// file = file.getAbsoluteFile();
// file = file.getCanonicalFile();
// } catch (Exception e) { System.out.println("e"); }
if (file.canWrite()) {
System.out.println("Writable: "+file);
} else {
System.out.println("** Not writable **: "+file);
}
chooser.setCurrentDirectory(file);
}
}
}
---------- END SOURCE ----------
(Incident Review ID: 216229)
======================================================================
- backported by
-
JDK-2200203 File.canWrite() returns false for the "My Documents" directory (win)
- Resolved
-
JDK-2189716 File.canWrite() returns false for the "My Documents" directory (win)
- Closed
-
JDK-2199461 File.canWrite() returns false for the "My Documents" directory (win)
- Closed
- duplicates
-
JDK-6895518 Unable to print to file in default print dialog box on Vista and Windows Server 2008
- Closed
-
JDK-6953475 File.canWrite() returns false for User Folders
- Closed
- relates to
-
JDK-4847375 JFileChooser Create New Folder button is disabled incorrectly
- Closed
-
JDK-6728842 File.setReadOnly does not make a directory read-only (win)
- Closed
-
JDK-2197766 File.setReadOnly does not make a directory read-only (win)
- Resolved
-
JDK-6203387 File.canRead() reports wrong value (win)
- Closed