How to determine what OS your java prog is running on?
Is there a Java command to determine what OS your program is running on?
Yes it IS important -- because there are things that are OS-specific, such as valid characters for filenames.
I could just disallow ALL "shady characters", but then my program would be skipping a lot of GOOD files in Linux, which only disallows the '/' character.
http://www.linuxboxadmin.com/articles/tools-and-utilities/linux/mac/windows-file-name-friction.html
Any ideas how I should proceed?
Matthew
[515 byte] By [
CathInfoa] at [2007-11-27 8:26:53]

That works for separator char, but what about valid characters in filenames?
What if I want a program to look at ALL FILES in a directory (open them, process them) except for those which will cause an error if I try to open them?
The list of "bad characters" varies by operating system.
Matthew
I assume, if it's looking at "ALL" files in a directory, that it is running in a loop, right? Well, put the try/catch in the loop, rather than around it, and let it throw an exception. Catch it and keep a list of files that didn't work. But then again, if you're talking about "reading" a file, this shouldn't be a problem, because if it is an invalid character, how did the file get there? and should it really be your worry?
As far as writing one with a character like that, let the user enter tha name he wants, attempt to create it, and if it fails ask for another, and for those filenames that you generate within the program, stick to the "safe" characters.