Discussion Locked

java

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
how can i know the number of partitions of the system by a java program.and also which operating system it is.

8 replies

by thechas

You need to call the specific keys in the registry files.
That is the only place that this data is stored.

There is a program that does this task, I don't know if it is using JAVA though.
Belarc Advisor www.belarc.com

After running the program, you get a web page that details the system.

I recommend that you look through the JAVA archives at www.builder.com.com
I believe thay had an article on extracting data from the registry.

Chas

by thechas

This Builder.com article is for Visual Basic, but it covers the type of data that you are looking for.

Retrieving system information using Visual Basic
Apr 27, 2001
Lamont Adams

Chas

by okujava

the number of partitions you get with the method:

File roots[] = File.listRoots();
so you will have the file objects for c:, d:, e: and so on.

the operating system you can get from system properties:

String os = System.getProperty("os.name");

it will return the value such as "windows 2000".

cheers

by bayard-generationjava

Number 2 is a good answer. Basically the answer is you can't get the partitions. But you can probably get away with it by:

1) Getting the OS as described previously.
2) If windows, then use listRoots.
3) If anything else then load /etc/fstab, parse it and use this.

Most alternative OSes follow a UNIX like structure, especially the popular ones. The biggest OSes I can think of that might not would be:

EPOC, Palm, OS9, OS/2

OS9 you can ignore as the listRoots() method is Java 1.2. OS/2 I would imagine you can ignore, ditto for EPOC. Palm can probably be ignored as well.

This discussion is closed to new replies.