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

How to get the name of CD drive?

 
Jim Wang
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Heath Lilley
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic