Searching...
Sunday, 4 August 2013

File Separator

A file separator is a character that is used to separate directory names that make up a path to a particular location.
It is operating system dependent. On Microsoft Windows,  it is a back-slash character (\) while on Mac OS and unix based operating system, it is forward slash(/).
By using the file.separator key from the system property, you can avoid checking for the OS.

Below is the example of File.separator

package com.java.everythingaboutselenium;
import java.io.File;
import java.io.IOException;

public class PathSeparator {
        public static void main(String[] args) {
                String path = "C:";
                String pathSep = path + File.separator + "Hello" + File.separator;
                System.out.println(pathSep);
        }
}

Output : C:\Hello\


0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Back to top!