不同系统之间获取路径的分隔符的兼容(转换)

String path= request.getSession( ).getServletContext( ).getRealPath( "/" );//获取绝对路径

String path2 = path.replace("\\",File.separator);//用File.separator 代替 分隔符 以适应各个系统(Windows,Linux)

posted @ 2016-01-14 21:00  落叶知途  阅读(563)  评论(0)    收藏  举报