Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Windows Error when discovering drives.

807606Jun 9 2007 — edited Jun 9 2007
Hello-
I am trying to get my app to discover what drives are on my machine.
I have the following code:
private void createDriveList(){
    List tempList = Collections.synchronizedList(new ArrayList());
driveList.add("A:/");
driveList.add("B:/");
driveList.add("C:/");
driveList.add("D:/");
driveList.add("E:/");
driveList.add("F:/");
driveList.add("G:/");
driveList.add("H:/");
driveList.add("I:/");
driveList.add("J:/");
driveList.add("K:/");
driveList.add("L:/");
driveList.add("M:/");
driveList.add("N:/");
driveList.add("O:/");
driveList.add("P:/");
driveList.add("Q:/");
driveList.add("R:/");
driveList.add("S:/");
driveList.add("T:/");
driveList.add("U:/");
driveList.add("V:/");
driveList.add("W:/");
driveList.add("X:/");
driveList.add("Y:/");
driveList.add("Z:/");
try{
for(int d=0;d<driveList.size();d++){
    String drive=(String)driveList.get(d);
    File Drive = new File(drive);
    if(Drive.exists()){
    if(Drive.isDirectory()&&Drive.canRead())tempList.add(drive);
}
}
    driveList= Collections.synchronizedList(new ArrayList());
    driveList=tempList;

}catch(Exception x){System.out.println(x.getMessage());}
}
If , one of my drives does not have a disk inserted into it,
Windows gives an error dialog titled "No Disk"
and allows me to continue or cancel.
Is there any way to escape this dialog?
Thanks for your help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 7 2007
Added on Jun 9 2007
1 comment
22 views