How can we distinguish System drives and external storage devices?
hello,
How can we detect the system drives and virtual drives? How can we distinguish between them? Using File.listRoots() method, we can get all the roots, but out of them how can we know which one is connected externally or through USB? Is there any other way? Please If you have knowledge about this, guide me.
Regards
Nikhil
thanx kaj,
If I execute my application first and then connect any storage USB device, application detects the newly connected device.
But, If the device is already connected, and then I start my application, It fails to detect the connected device.
I am using File.listRoots() method, which lists all the currently available roots, roots may be system drives or connected USB drive. this will clear the idea.
If you know any other way or atleast idea please tell me.
Regards
Nikhil
Hello CeciNEstPasUnProgrammeur
I studied and implemented some of methods in the class FileSystemView. This is really helpfull to me, I have sorted out my problem. Thanks a lot.
Following example code snippet prints distinguishing characters:-
import java.io.*;
import javax.swing.filechooser.FileSystemView;
public class TryVirtualDrive
{
public static void main (String args[])
{
File[] roots = File.listRoots();
for(int i=0; i< roots.length; i++)
{
System.out.println(FileSystemView.getFileSystemView().getSystemTypeDescription(roots));
System.out.println(FileSystemView.getFileSystemView().getSystemDisplayName(roots));
System.out.println();
}
}
}
Regards
Nikhi Shravane