Display path separator in Java


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 :

Updated on: 30-Jul-2019

151 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements