Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java - get Drive VolumeName

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

610 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