P
Patrick Ma
Hi,
What is your preferred way to write OS filesystem independent Java program?
The Java program will need to both read and write to files. This is a server
side Java program that has total access to the filesystem.
For reading files, one can use the "resource anchor class" and
Class.getResourceAsStream(). This is nice because the root path is
represented by the "resource anchor class" instead of "C:\" or "\usr".
However, this is a read only solution. Is there a "write" counter-part to
this?
Do you prefer to specify a root path, such as "C:\" or "\usr" in your
program and have a Singleton access method to return the root path based on
looking up the OS property in System?
What other ways can you think of?
Thanks.
What is your preferred way to write OS filesystem independent Java program?
The Java program will need to both read and write to files. This is a server
side Java program that has total access to the filesystem.
For reading files, one can use the "resource anchor class" and
Class.getResourceAsStream(). This is nice because the root path is
represented by the "resource anchor class" instead of "C:\" or "\usr".
However, this is a read only solution. Is there a "write" counter-part to
this?
Do you prefer to specify a root path, such as "C:\" or "\usr" in your
program and have a Singleton access method to return the root path based on
looking up the OS property in System?
What other ways can you think of?
Thanks.