Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. public class RequirementsCoverage {
  2.  
  3.     public static void writeToFile(String append) {
  4.         String filePath = "src/main/resources/requirements_coverage/requirements_coverage.txt";
  5.         String content = "";
  6.         try {
  7.             content = new String(Files.readAllBytes(Paths.get(filePath)));
  8.         } catch (IOException e) {
  9.             System.out.println("An error occurred.");
  10.             e.printStackTrace();
  11.         }
  12.         if (!content.contains(append)){
  13.             try {
  14.                 FileWriter myWriter = new FileWriter(filePath);
  15.                 myWriter.write(content + "\n" + append);
  16.                 myWriter.close();
  17.                 System.out.println("Successfully wrote Requirements coverage to the file.");
  18.             } catch (IOException e) {
  19.                 System.out.println("An error occurred.");
  20.                 e.printStackTrace();
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement