Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public static void launchReport() {
  2. double date = 0;
  3. File latest = null;
  4. File folder = new File("public/reports");
  5. File[] listOfFiles = folder.listFiles();
  6. for (int i = 0; i < listOfFiles.length; i++) {
  7. if (listOfFiles[i].isFile()) {
  8. if (date < listOfFiles[i].lastModified()) {
  9. date = listOfFiles[i].lastModified();
  10. latest = listOfFiles[i];
  11. }
  12. }
  13. }
  14. File htmlFile = new File(latest.getAbsolutePath());
  15.  
  16. try {
  17. String content = new String ( Files.readAllBytes( Paths.get(latest.getAbsolutePath()) ) );
  18. System.out.println(content);
  19. content = content.replaceAll("<span class=\"test-status right pass\">pass</span>", "<span class=\"test-status right pass\">Complete</span>");
  20. PrintWriter out = new PrintWriter(latest.getAbsoluteFile());
  21. out.print(content);
  22. out.close();
  23. Desktop.getDesktop().browse(htmlFile.toURI());
  24. } catch (IOException e) {
  25. e.printStackTrace();
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement