aspose file tools*
The moose likes Servlets and the fly likes How to get the name of CD drive? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get the name of CD drive?" Watch "How to get the name of CD drive?" New topic
Author

How to get the name of CD drive?

Jim Wang
Ranch Hand

Joined: Oct 04, 2001
Posts: 41
I have a servlet need to read PDF file from CD and I can get the name of file from the database. My problem is I don't know which name of the CD drive will be used later (d, e, f ...)? Since I can't make the CD drive's name hardcoded in my code, I wonder is there a way to figure it out from the system?
Jim
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Not every computer has exactly one CD drive, and Java doesn't have a lot of support for hardware sniffing, since that's not easy to do in a system designed for portability.
However, you can manually provide the drive ID via a servlet startup parameter and avoid hard-coding it in program logic. Or better yet, put the whole PDF path there, in case you need to move it later.


Customer surveys are for companies who didn't pay proper attention to begin with.
Heath Lilley
Ranch Hand

Joined: Jan 09, 2001
Posts: 72
I agree with Tim.
The init parameter is a good idea, however, I would set up a property file of some sort that has the drive path in it (along with any other application properties), and create a class that reads from that file. This allows you to only have to change the property file when you create the web application on a new machine. The property files and their java counterparts (ResourceBundles) work on Windows, Linux, and Solaris machines. I am sure they would work on any other system that has an updated JVM.
Hope this Helps
Heath
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the name of CD drive?