How do I get path / classpath separtor?

Bookmark this example!  
Category: java.lang, viewed: 1682 time(s).

OS platform have different symbol used for path separator. Path separator is a symbol that separate one path element from the other. In Windows you have something like:

.;something.jar;d:/libs/commons.jar

While on Linux operating system it looks like:

.:something.jar:/libs/commons.jar

To obtain the path separator you can use the following code.

 
package org.kodejava.sample.java.lang;
 
import java.util.Properties;
 
public class SystemProperties
{
    public static void main(String[] args)
    {
        // Get System properties
        Properties properties = System.getProperties();
 
        // Get the path separator which is unfortunatelly
        // using a different symbol in different OS platform.
        String pathSeparator =
                properties.getProperty("path.separator");
        System.out.println("pathSeparator = " + pathSeparator);
    }
}
 
 
Can't find what you are looking for? Join our FORUMS and ask some questions!

Most Viewed Examples

Latest Code Examples

100 Top & Latest


Locations of visitors to this page
eXTReMe Tracker
visitor stats
Get Chitika Premium