要得到web application中的classes路径可以使用如下方法:
1.先查出是WINDOWS操作系统还是LINUX操作系统:

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操作系统还是LINUX操作系统:



















