i tried the following program
import java.io.*;
class dr
{
public static void main(String args[])
{
try{
File[] roots = File.listRoots();
for (int index = 0; index < roots.length; index++)
{ //Print out each drive/partition
System.out.println(roots[index].toString());
}
}
catch(Exception e)
{
System.out.println("error " +e);
}
}
}
but in my system floppy drive is not connected and i am getting a message like the following
" The drive is not ready for use;its door may be open,Please check drive A: and make sure that disk is inserted and that the drive door is closed" then three options are shown cancel,try again,continue when i try continue,it works but how i could avoid that msg
}
reference : http://littletutorials.com/2008/03/10/getting-file-system-details-in-java/
When it comes to Windows, this class
WindowsAltFileSystemView
proposes an alternative based on FileSystemViewSo here, the idea is to extends
FileSystemView
, replacing thegetRoots()
method with:you can use this;
What are you trying to do?
My recommendation would be to use FileSystemView.
It's used something like this: