File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Floppy

 
Zein Nunna
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 410
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 410
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 410
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Zein Nunna
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same issue as Jesper.

Im using eclipse 3.0 and XP Pro (SP2).
 
Stuart Gray
Ranch Hand
Posts: 410
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic