Link to home
Start Free TrialLog in
Avatar of atombender
atombender

asked on

disk volume label

how can i read the volume label of a disk?
i want to build a cd catalog-application
it just has to run on windows
Avatar of Ovi
Ovi

If you want to use JDK 1.4 you don't have to ask yourself this question, itdoes automatically this for you. Try to use for example a JFileChooser from JDK1.4.

If not, I believe with native code invoked by Java (Using Runtime.getDefaultRuntime().execute("cmd") and reading from the input stream of the resulted process).
Correction : (Using Runtime.getRuntime().execute("cmd") ....
Avatar of atombender

ASKER

unfortunately i have jdk1.3
import java.io.*;

public class Test{
     public static void main(String args[])throws Exception{
          Runtime rt=Runtime.getRuntime();
          Process p=rt.exec("chkdsk f:");
          BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
          System.out.println(in.readLine());
          System.out.println(in.readLine());
          p.destroy();
         
     }
}
OUT PUT IS
The type of the file system is FAT32.
Volume PROGRAMS created 10/22/2001 9:39 AM

Its a bit funny .. but belive me reads the Volume label and type of drive F, there on Windows XP with JRE 1.3.. if ya have ne other progam that could write the Disk Volume you can use instead.. as i used chkdsk.. no internal command i think

points as it works :-) kiddin
ASKER CERTIFIED SOLUTION
Avatar of msterjev
msterjev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Some comment.....