drive types...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: drive types...

  1. #1
    Join Date
    Nov 2002
    Posts
    138

    drive types...

    does Java have a way of telling if a drive is a floppy, hard/fixed disk, CD, etc? basing on some classes in JDK1.4, i've learned that Java assumes that a & b ( i'm making this on windows ) are always floppy drives, and the rest would just be another type of drive. it doesn't give any distinction.

    so far, the only solution i have come to think of is to add natives which will be responsible for identifying drive types.

    anyone?

  2. #2
    Join Date
    Aug 2002
    Posts
    94
    Hi,

    Interestin question!

    I browsed through the java docs rather quickly but cannot find anything. You have mentioned some classes that helps java assume that "a" and "b" are floppu drives - which classes or packages are these.

    Post the details and we may be able to dig a little deeper together.
    bye

  3. #3
    Join Date
    Nov 2002
    Posts
    138
    ya, and no one seems to anwer this question in all the forums i've been. so far the only class that i've seen that somehow deals with my question is javax.swing.filechooser.FileSystemView.java. check it out and you'll see... but i read this class in when i still had JDK1.3.1. i'm not sure if some things change in 1.4 but i'm sure there isn't too big a change or none at all. do tell me if there are other classes that are related. thanks!

  4. #4
    Join Date
    Aug 2002
    Posts
    94
    According to JDK 1.4 docs the following contains the functionality you desire (as you've already figured out and mentioned in your msg):
    javax.swing.filechooser.FileSystemView

    typically the methods that you need are :
    1) boolean isFloppyDrive(File dir) ;
    2) boolean isDrive(File dir)
    3) String getSystemDisplayName(File f)


    the last one according to JDK docs is multipurpose as it returns the information as string.

    For example from Windows: the "M:\" directory displays as "CD-ROM (M: ) "

    If you need more help then feel free to post here or start a new thread.
    bye

  5. #5
    Join Date
    Nov 2002
    Posts
    138
    I don't know about you but, some of the methods in this particular class ain't working. For the 3 methods that you have mentioned, only 1 works fine - getSystemDisplayName( File f ). and this method doesn't say (C Fixed Drive, or (D CD-ROM drive. it gets the system name instead, e.g (D The Journeys of Jain Farstrider. the other 2 doesn't work. the documentation says that - "default implementation has no way of knowing so always returns false...". besides, if it did work at all, this doesn't answer my question. all 3 methods doesn't answer it. what i wanted was a way of knowing what drive is a floppy, fixed, a CD-ROM or other particular drive/partition. i got stuck in my project because of this since i didn't test it first before i proposed my project. i was so confident that it would work. and it wasn't even close to my project implementation. hahaha.... i made another class instead that assumes this and that and it sucks! but it got me curious though. incorporating C++ or C, natives, would be a solution. can you suggest another?

  6. #6
    Join Date
    Oct 2002
    Posts
    66
    Hmm...I've not come across any of this but I was gonna suggest you use the JNI to write a little C module to do it. I'm sure it can't be too hard to work out (though whenever anyone says that it ends up being extremely difficult, heh!) and there's probably already some modules written that will do this.

    Otherwise, I'd suggest that you use your previously written solution and state that you had many troubles overcomming it and also suggest alternatives. This will often get as many marks as doing exactly what is asked.

    Hope that helps.
    Meethoss

  7. #7
    Join Date
    Nov 2002
    Posts
    138
    that's what i said, right? the only solution i can think of is by using natives - JNI - if you call it. i'll have to review a little on my C. i was only up to file-handling until they made us shift to Java. i doubt an all Java solution is there at all...

  8. #8
    Join Date
    Aug 2002
    Posts
    94
    oK. I'll have to try the methods I posted above to check why it is not giving the intended functionality. Presently hard pressed for time so you may have to wait till week end.

    In the meantime I recommend you search/post the forums at java.sun.com - the official homepage of Java.

    Good luck!

  9. #9
    Join Date
    Nov 2002
    Posts
    138
    nobody replies there! everyone's posting and noone replies. hahaha.... if the posts here can be compared to a church on monday, there it's like Mars...

  10. #10
    Join Date
    Nov 2002
    Posts
    138
    pardon but it should not have been "if the posts here can be compared....", but rather the replies. at least here even if the replies are nowhere close to the answer one wants, and i am not pointing to anyone, you still get one or two...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center