【发布时间】:2015-01-27 13:04:54
【问题描述】:
我有一个旧的 java 项目。我为该项目创建了战争文件。我修改了项目中给出的路径例如:
........
old path=ReportUtil.startTesting(System.getProperty("user.dir")+"//Test_Reports//Suite_Report.html");
new path=ReportUtil.startTesting("/Test_Reports/Suite_Report.html");
.......
运行文件时显示如下消息=:“ERROR [STDERR] Error: \Test_Reports\Suite_Report.html(系统找不到指定的路径)”。
我该如何克服这个错误,我需要你们所有人的建议,提前谢谢。
代码
`HybridFramework.java
--------------------
public static void startTesting()
{
ReportUtil.startTesting("/Test_Reports/Suite_Report.html");
}
ReportUtil.java
----------------
public static void startTesting(String filename)
{
String indexResultFilename = filename;
String currentDir = indexResultFilename.substring(0,indexResultFilename.lastIndexOf("/"));
FileWriter fstream =null;
BufferedWriter out =null;
try{
fstream = new FileWriter(filename); //--------->here only showing the error "The system cannot find the path specified"
out = new BufferedWriter(fstream);
}
catch(Exception e)
{
System.err.println("Error: " + e.getMessage());
}
}`
【问题讨论】: