?
Solved

Java - get Drive VolumeName

Posted on 2006-11-11
3
Medium Priority
?
1,452 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

764 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