要得到web application中的classes路徑可以使用如下方法:
1.先查出是WINDOWS操作系統(tǒng)還是LINUX操作系統(tǒng):
private boolean isWindows(){
String operatorSystemName = System.getProperty("os.name");
operatorSystemName = operatorSystemName.toUpperCase();
if(operatorSystemName.indexOf("WIN")>0){
return true;
}
return false;
}
2.得到classes路徑:
String path = null;
path = this.getClass().getResource("/") + "Senders.txt";
path = path.substring(6,path.length());
if(!this.isWindows()){
path += "/" + path;
}
例外,在windows一般文本換行符為:"\r\n",而在liunx之中則為:"\n".
1.先查出是WINDOWS操作系統(tǒng)還是LINUX操作系統(tǒng):













