Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > List of disc devices in a system

Reply
Thread Tools

List of disc devices in a system

 
 
Lino
Guest
Posts: n/a
 
      07-31-2006
Hello,
With File.listRoots() I can get the list of roots (devices) in a
system. The problem I'm having is that I'm getting the DVD unit
although it was empty. Does anybody know how to know if the DVD unit is
empty? With File.exists() I can know it but a message box with the
error appears and I want to avoid the appearing of this box.
Thanks in advance.

 
Reply With Quote
 
 
 
 
Martin Lansler
Guest
Posts: n/a
 
      07-31-2006
Hi Lino,

Well I did not have any problems with my DVD drives, my floppy drive however
caused an error message to be displayed:

import java.io.File;

public class ListRoots {
public static void main(String[] args) {
File[] roots = File.listRoots();
File[] ignoreRoots = new File[] { new File("a:\\") };
listRoots: for (File file : roots) {
for (File ignoreRoot : ignoreRoots) {
if (file.equals(ignoreRoot)) {
System.out.println("[ignored]" + file);
continue listRoots;
}
}
System.out.println((!file.canRead() ? "[not available]" : "") +
file);
}
}
}

Running the code above on a Windows XP gave:
[ignored]A:\
C:\
D:\
[not available]E:\
[not available]F:\
[not available]Z:\

So maybe a workaround would be to ignore the floppy drive as the code above
does - which roots to ignore could be configurable in your application.

Cheers,
Martin.

"Lino" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello,
> With File.listRoots() I can get the list of roots (devices) in a
> system. The problem I'm having is that I'm getting the DVD unit
> although it was empty. Does anybody know how to know if the DVD unit is
> empty? With File.exists() I can know it but a message box with the
> error appears and I want to avoid the appearing of this box.
> Thanks in advance.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Disc Cannot Be Played... Please Check The Disc"? (PeteCresswell) DVD Video 3 01-13-2007 12:26 AM
Toshiba Unveils 45GB HD DVD-ROM Disc and Hybrid ROM Disc. Allan DVD Video 0 07-11-2005 01:05 PM
Can security devices harm DVDs and electronic devices? curious@nospam.com DVD Video 12 03-02-2005 06:57 AM
"Windows CE Devices and Palm Devices Help Needed" Naveen Vaila ASP .Net Mobile 1 06-23-2004 10:12 AM
DVD 2 disc vs. DVD 1 disc? Confused Wootikus DVD Video 16 09-28-2003 09:30 AM



Advertisments