3、了解java的文件4种分隔符

java.io.File类中有四种静态分隔符; 分别是separator separatorChar pathSeparator pathSeparatorChar

separator : 它属于平台默认的字符形式, 列如window "\" unix "/"
separatorChar : 同上,但是表示字符
pathSeparator : 表示为各个平台classPath 分割的变量,window: ";" unix ":"
pathSeparatorChar : 同上,但是表示字符

测试============

package com.tij.io.file;

import java.io.File;

/**
* 了解文件分隔符
* @author guoyoujun
* @date 2014-3-16
*/
public class FileSeparator {

/**
* ava.io.File class contains four static separator variables. Here we will learn about them and when to use it.
s eparator: Platform dependent default name-separator character as String. For windows, it’s ‘\’ and for unix it’s ‘/’.
separatorChar: Same as separator but it’s char.
pathSeparator: Platform dependent variable for path-separator. For example PATH or CLASSPATH variable list of paths separated by ‘:’ in Unix systems and ‘;’ in Windows system.
pathSeparatorChar: Same as pathSeparator but it’s char.
* @param args
*/
public static void main(String[] args) {
System.out.println("File.separator = "+File.separator);
System.out.println("File.separatorChar = "+File.separatorChar);
System.out.println("File.pathSeparator = "+File.pathSeparator);
System.out.println("File.pathSeparatorChar = "+File.pathSeparatorChar);
}

}

out put =============
window:
File.separator = \
File.separatorChar = \
File.pathSeparator = ;
File.pathSeparatorChar = ;

unix:
File.separator = /
File.separatorChar = /
File.pathSeparator = :
File.pathSeparatorChar = :

你可能感兴趣的:(IO)