Get file system separator in Java
Description
The following code shows how to get file system separator.
Example
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
//from www . j av a2 s .c o m
public class Main {
public static void main(String[] args) throws Exception {
String separator;
separator = FileSystems.getDefault().getSeparator();
System.out.println("The separator is " + separator);
}
}
The code above generates the following result.