コード例 #1
0
ファイル: BaseTest.java プロジェクト: chrreisinger/antlr4
 public static void writeFile(String dir, String fileName, String content) {
   try {
     File f = new File(dir, fileName);
     FileWriter w = new FileWriter(f);
     BufferedWriter bw = new BufferedWriter(w);
     bw.write(content);
     bw.close();
     w.close();
   } catch (IOException ioe) {
     System.err.println("can't write file");
     ioe.printStackTrace(System.err);
   }
 }
コード例 #2
0
  private void populateFile(String fileName, String contents) {
    File testFile = new File(testMeta.getDir() + "/" + fileName);

    try {
      testFile.createNewFile();
    } catch (IOException ex) {
      DTThrowable.rethrow(ex);
    }

    FileWriter fileWriter;

    try {
      fileWriter = new FileWriter(testFile);
      fileWriter.write(contents);
      fileWriter.close();
    } catch (IOException ex) {
      DTThrowable.rethrow(ex);
    }
  }