How to identify classpath separator for a specific OS

I am reading the classpath using System.getProperty("java.class.path") and I am trying to analyze each entry using a tokenizer. I noticed that in Windows the classpath entries are separated by a ';', and in Unix it's a ':' (I noticed this in Ubuntu Linux). Does anyone know how to identify the classpath separator for a specific OS/file system?

Go through the java.lang.System class, and there is a method called something like getProperties. That returns a Properties object, which has methods like list. Using that method you should be able to get a listing of all Properties; there will be one called something like path.separator.

Now back to the System class and use getProperty("path.separator") only you use the correct spelling.

Kjeld Sigtermans
Ranch Hand

Joined: Aug 10, 2006
Posts: 127

posted Apr 21, 2008 15:59:00

0

Thanks.

path.separator and file.separator are the ones I was looking for. I used them once before, but just couldn't remember how I did that:-)