Display path separator in Java

Java 8Object Oriented ProgrammingProgramming

To display the path separator, use the Properties class and import the following package −

import java.util.Properties;

Use the getProperties() method first and create an object −

Properties p = System.getProperties();

Now, set the key for path separator −

p.getProperty("path.separator")

The following is an example −

Example

 Live Demo

import java.util.Properties;
public class Demo {
   public static void main(String[] args) {
      Properties p = System.getProperties();
      System.out.println("Separator is "+p.getProperty("path.separator"));
   }
}

Output

Separator is :
raja
Published on 21-Dec-2018 15:45:07
Advertisements