wood burning stoves 2.0*
The moose likes Java in General and the fly likes Floppy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Floppy" Watch "Floppy" New topic
Author

Floppy

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hey guys,

I just wanted to know how I could possible check if there is a floppy in the drive or not?

Could you point me in the direction of the method?

Thanks

Zeim
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Make a file that represents the floppy drive, and then check if it exists:

Of course, this could also mean there is no floppy drive at all. To check that, use File.listRoots() and see if A (or B) appears in the list.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Stuart,

Thats great. Thanks.

What I want to now is to overide the default "No disk" pane. So instead of it saying try again etc.. I can have something of my own.

Regards
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Which no disk pane? One provided by the OS? When I tried the above code it just printed out 'false'; i didn't get any 'no disk' error or anything.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Stuart,

If you try the above (access the floppy), but the floppy is empty, Java provides a pane that says to insert a disk, cancel try again and contiue are the options available.

The pane is provided by Java, as the title of the pane says Javaw.exe.

How do I overwrite that? Can I even override it?

Thanks in advance

Zein
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Really? I tested that code using JCreator on XP Pro (SP2) and I recieved no such pane. My drive just grinded for a few seconds
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

I don't believe that javaw.exe does this explicitly. It's a long time ago that I was writing Windows applications in C++, but I remember that disabling that message wasn't easy.

When I run the example code, I get a small window with the title "Windows - No Disk", and the text: "There is no disk in the drive. Please insert a disk into drive .", and three buttons (Cancel, Try Again, Continue). I'm running Windows XP SP2.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
I have the same issue as Jesper.

Im using eclipse 3.0 and XP Pro (SP2).
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Yes, I just tried it again but from the command line instead of from JCreator and I get the message too.
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Is there anyway I could modify that message using Java? What i want to do is for the message to display the name of the missing disk? [which is different through out the app]

I suppose an alternative would be to use C++, but that would mean I have to learn a whole new language etc. for such a trvial issue?

Thanks in advance for any advice/pointers/cues

Zein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Floppy