0

I have a flash drive named "SCHOOL". In my computer, it's registered as the F: drive. Instead of pointing to the F: drive, as it'd be different on any other computer, could I just point towards a drive named "SCHOOL" instead?

If I couldn't do this, is there a way I could always point towards this flash drive no matter how many storage devices are plugged into my computer?

Kara
  • 6,115
  • 16
  • 50
  • 57
EpicBlargh
  • 1
  • 1
  • 5

2 Answers2

1

It is not possible. The only way I can think of is using some sort of a bat file / java class and identify each drive by name by checking out all available drive letters.

You can get all root directories (drive letters in windows) using:

File [] drives = File.listRoots());
Martin Kersten
  • 5,127
  • 8
  • 46
  • 77
0

Well Not directly but possible as following:

FileSystemView fsv = FileSystemView.getFileSystemView();
File[] roots = File.listRoots();
File fDrive;
for(File f : roots)
{
  String displayName = fsv.getSystemDisplayName(f);
  System.out.println(displayName);
  if(displayName.indexOf("SCHOOL") != -1)
  {
    fDrive = f;
    break;

  }
}
Sage
  • 15,290
  • 3
  • 33
  • 38
  • Perfect. Thank you so much for this! It worked exactly as expected, and I have my program working. MUCH appreciated! – EpicBlargh Oct 03 '13 at 00:42
  • well if you think so, mark the answer as Accepted. It will help other peoples to find the "way of doing!" – Sage Oct 03 '13 at 01:05