File.separator之java中通用转义字符的使用

separator 
public   static   final   String   separator 
The   system-dependent   default   name-separator   character,   represented   as   a   string   for   convenience.   This   string   contains   a   single   character,   namely   separatorChar.   

separatorChar 

public   static   final   char   separatorCharThe   system-dependent   default   name-separator   character.   This   field   is   initialized   to   contain   the   first   character   of   the   value   of   the   system   property   file.separator.   On   UNIX   systems   the   value   of   this   field   is   '/ ';   on   Microsoft   Windows   systems   it   is   '\ '.                                                          

使用方法

static String indexPath="E:"+File.separatorChar+"IRSpace"+File.separatorChar+"lucenspace";

在windows中相当于

static String index_Path="E:\\IRSpace\\lucenspace";

你可能感兴趣的:(java)