【问题标题】:ERROR [STDERR] Error: \Test_Reports\Suite_Report.html (The system cannot find the path specified)?ERROR [STDERR] 错误:\Test_Reports\Suite_Report.html(系统找不到指定的路径)?
【发布时间】: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());
}

}`

【问题讨论】:

    标签: java eclipse jsp jboss5.x


    【解决方案1】:

    试试new path=ReportUtil.startTesting("//Test_Reports//Suite_Report.html")

    【讨论】:

    • 您好,现在尝试了您的建议,它显示错误为“找不到网络路径”,但之前显示消息为“系统找不到指定的路径”
    • new path=ReportUtil.startTesting(".//Test_Reports//Suite_Report.html")怎么样
    • 我给了新的 path=ReportUtil.startTesting("//Test_Reports//Suite_Report.html") 它显示错误消息为 ERROR [STDERR] Error: \\Test_Reports\Suite_Report.html (The未找到网络路径)
    • 也许只是new path=ReportUtil.startTesting("Test_Reports//Suite_Report.html")?也试试绝对路径...
    • 我尝试了你所有的建议,但也没有用。它显示错误为“系统找不到指定的路径”
    【解决方案2】:

    // 很可疑,这里应该是/

    我假设目录 Test_Reports 是手动创建的(并且在具有足够权限的 Linux 上)。

    还要注意FileWriter 使用当前平台编码。如果你想处理完整的 Unicode,最好使用 OutputStreamWriterStandardCharsets.UTF_8。在 HTML 中应添加相应的元字符集语句。

    【讨论】:

      猜你喜欢
      • 2020-05-27
      • 2017-02-05
      • 2015-11-28
      • 1970-01-01
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 2019-12-22
      • 2020-06-24
      相关资源
      最近更新 更多