Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. Thread t = new Thread() {
  2. @Override
  3. public void run() {
  4.  
  5. BufferedReader reader = null;
  6. try {
  7. reader = new BufferedReader(new FileReader(LOGFILE));
  8. String line;
  9. while (running) {
  10. line = reader.readLine();
  11. if (line == null) {
  12. // wait until there is more lines in the file
  13. Thread.sleep(POLL_MS);
  14. } else {
  15. // append to the log Label
  16. synchronized (MyApplication.this) {
  17. log.setValue(log.getValue() + line + "<br />");
  18. }
  19. }
  20. }
  21. } catch (IOException e) {
  22. // TODO: handle me
  23. e.printStackTrace();
  24. } catch (InterruptedException e) {
  25. // TODO: handle me
  26. e.printStackTrace();
  27. } finally {
  28. running = false;
  29. if (reader != null) {
  30. try {
  31. reader.close();
  32. } catch (IOException ignore) {
  33. }
  34. }
  35. }
  36.  
  37. }
  38. };
  39. t.start();
  40.  
  41. ProgressIndicator pi = new ProgressIndicator();
  42. pi.setPollingInterval(POLL_MS);
  43. pi.setIndeterminate(true);
  44. layout.addComponent(pi);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement