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.





















Home »
  Java Tutorial »
    I/O »




Binary File
Byte Array
CharSet
Checksum
Console
Create Copy Move Delete
Directory
Drive
Encode Decode
File Attribute
File Lock
File System
GZIP
Jar File
NIO Buffer
Path
Scanner
StreamTokenizer
Temporary File
Text File
Zip