Solved

Java - get Drive VolumeName

Posted on 2006-11-11
3
1,449 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse console opening separately 2 45
Is there a simpler dropbox system? 10 50
collection output issue 9 88
listing all the respondents to a twitter feed - Java 5 40
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 had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

740 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