0

Is there a cleaner way in getting the root directory name, drive letter, or computer name of a given directory other than string manipulation?

For example:

C:\myfolder\file.txt will return C:\

//NETWORK_COMPUTER/myfolder/file.txt will return //NETWORK_COMPUTER/

/temp/myfolder/file.txt will return /temp/

Note: I have already checked Get partition name from drive letter and vice versa and Fetching file and path from network using java.

Also, this problem is restricted to JDK 6

Community
  • 1
  • 1
Marl
  • 1,492
  • 2
  • 22
  • 37
  • Use [Files.getFileStore](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getFileStore-java.nio.file.Path-) to get the FileStore of the directory, then see http://stackoverflow.com/questions/10678363/find-the-directory-for-a-filestore . – VGR Mar 16 '15 at 01:42
  • I forgot to note that this problem is a jdk 6 restricted. – Marl Mar 16 '15 at 01:50

0 Answers0