How to tell if a drive is local or remote in Java ????

G

Gil Blais

Does anyone know how to do this? Would surely help me right now...

Thanks in advance, Gil Blais
 
B

Boudewijn Dijkstra

Gil Blais said:
Does anyone know how to do this? Would surely help me right now...

Runtime.exec(new String[] {"C:\Windows\System32\net.exe", "use"});
 
O

Oscar kind

Gil Blais said:
Does anyone know how to do this? Would surely help me right now...

The subject I see in my newsreader is:
"How to tell if a drive is local or r"

So please restate your question in the body of your post. Also, the part I
do see raises one important question: what is a "drive"?

If by chance you mean a "disk drive", as Windows denotes by a letter, then
no: this is not possible, because it is OS specific. Compare to Linux:
- the entire filesystem is one tree (instead of up to 26 with Windows)
- any directory can be mounted from several sources, such as another
harddisk, a floppy disk, CD-ROM drive, NFS share, Windows share, etc.

In any case (at least using either Windows or Linux), the OS takes care of
all those details and you don't know if a file location is remote or not.

In a Java program, I find it best to use this distinction:
- If it is represented as a File, it is local.
- If it is represented as a URL, it can be remote; so treat it as such.
 
S

Steve Horsley

Gil said:
Does anyone know how to do this? Would surely help me right now...

Thanks in advance, Gil Blais
I don't think there is a pure java way.

You could search the file /etc/mtab and see if a parent directory
is listed there.

Steve
 
N

nwc

Why does it matter to you? If it's matter of choosing among available
drives for temp space, for example, you could select one based on how long
it takes to write something and read it back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top