急~~java、web下的路径的问题
我已经拼装好了所需的路径但还是报错,请高手指点指点
我的文件放在web下的downLoadpic文件夹下
我的思路:
1、我用String path = Thread.currentThread().getContextClassLoader().getResource("").toString() ;
得到路径path:file:/D:/workspace/webSphereWeb/web/WEB-INF/classes/
2、int index = path.indexOf("WEB-INF");
path = path.substring(0,index)+"downLoadpic/configure.txt";
3、打印path得到:file:/D:/workspace/webSphereWeb/web/downLoadpic/configure.txt (这个路径是文件存放的正确路径)
4、try {
File file = new File(path);
InputStream is = new FileInputStream(file);
……
……
}catch (IOException e) {
e.printStackTrace();
}
运行的时候却抱:java.io.FileNotFoundException: file:\D:\workspace\webSphereWeb\web\downLoadpic\configure.txt (文件名、目录名或卷标语法不正确。