Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Reading a file from CD/DVD.  (Read 888 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Member




Java games rock!


« Posted 2007-05-13 13:08:01 »

The java.io has alot of classes for reading and writing. I know I can use the path of my CD/DVD player to make java read from it but if I did not know the path, how can I detemine that during runtime i.e what path my primary cd/dvd device has?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #1 - Posted 2007-05-13 15:16:22 »

You can't.

You can make a lame guestimate though:

 // Java 6 required
for(File root: File.listRoots())
   if(!root.canWrite() && root.getFreeSpace() == 0)
      // prolly CD/DVD ?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline zappsweden

Junior Member




Java games rock!


« Reply #2 - Posted 2007-05-13 22:35:28 »

Thanks, saves me alot of time not trying to find something that does not exist Smiley
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline CommanderKeith
« Reply #3 - Posted 2007-05-14 03:06:25 »

I've got a feeling that there must be a more concrete way of doing it since the native look and feel JFileChooser can give a cd-icon to cd & dvd drives.  Not sure how it does it though.  Maybe you can look into the source for the native JFileChooser and figure it out from there???

Keith

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #4 - Posted 2007-05-16 11:50:59 »

Be careful - test this. A lot of drives do weird stuff if you try to access them when they're not ready, such as blocking Windows Explorer for a minute or more whilst trying to find the disk (or Flash card etc) they think you have in there but you don't.

malloc will be first against the wall when the revolution comes...
Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #5 - Posted 2007-05-16 13:40:17 »

Just prompt the user, its the only catch-all solution.

My home pc has 1 cd drive, 1 dvd drive and 4 vitual cd drives - There is no way you can programatically determine the correct one.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
hobbles (8 views)
2013-05-22 00:54:55

cubemaster21 (75 views)
2013-05-17 21:29:12

alaslipknot (87 views)
2013-05-16 21:24:48

gouessej (116 views)
2013-05-16 00:53:38

gouessej (111 views)
2013-05-16 00:17:58

theagentd (122 views)
2013-05-15 15:01:13

theagentd (111 views)
2013-05-15 15:00:54

StreetDoggy (156 views)
2013-05-14 15:56:26

kutucuk (178 views)
2013-05-12 17:10:36

kutucuk (176 views)
2013-05-12 15:36:09
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.075 seconds with 22 queries.