在java中打印到多个输出文件

Ed *_*ota 0 java

我有两个数组要打印到单独的文件.这是我的代码:

    try {
      PrintStream out = new PrintStream(new FileOutputStream(
          "Edges.txt"));
      for (i = 0; i < bcount; i++) {
        out.println(b[i][0] + " " + b[i][1]);
      }
      out.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }



    } catch (Exception ex) {
    ex.printStackTrace();
    }

    try {
      PrintStream out = new PrintStream(new FileOutputStream(
          "Nodes.txt"));
      for (i = 0; i < bigbIter; i++) {
        out.println(bigb[i]);
      }
      out.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }



    } catch (Exception ex) {
    ex.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

如果我只使用第一组try/catch/catch,它就能完美运行.但是当我使用它们时它不起作用,给我错误"非法启动类型...}捕获"和"错误:类,接口或枚举预期".我究竟做错了什么?

SLa*_*aks 5

} catch (FileNotFoundException e) {
  e.printStackTrace();
}



} catch (Exception ex) {
ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

你有一个额外的},它会抛出解析器,并给你很多错误.