Solved

Java - get Drive VolumeName

Posted on 2006-11-11
3
1,451 Views
Last Modified: 2011-04-14
Is it possible in Java to find the VolumeName of CD/DVD/Hard Disk?

I really want to know if this can be done purely in Java, I know I could write code to do this in C++ and use JNI, but that's not really what I'm after.

Note, I asked this question a long time ago for C# and got a perfect solution: http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21409394.html

Problem is I had a hard disk crash and lost the program I wrote in C#.  Now I want to write it again but this time in Java.  I don't use .Net anymore, I don't even have .Net installed and don't really want to install it.

Can it be done?
0
Comment
Question by:basicinstinct
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 500 total points
ID: 17924018
Please see if the following suits your need:

import javax.swing.filechooser.*;
import java.io.*;

public class Test {
      public static void main(String[] args) {
            FileSystemView v = FileSystemView.getFileSystemView();
            for (File f : File.listRoots())
                  System.out.println(v.getSystemDisplayName(f));
      }
}
0
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 17924024
0
 
LVL 23

Author Comment

by:basicinstinct
ID: 17924157
pkwan

That is EXACTLY what I needed, and your sample code was perfect.  
Thank you, you are a scholar and a gentleman.

Top marks, grade A, well deserved.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question