Advertisement
Guest User

Monitor File using java

a guest
Mar 3rd, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import java.io.*;
  2. public class LogMonitor
  3. {
  4. public static void main(String[] args) throws Exception
  5. {
  6. FileReader fr = new FileReader("D:/test.txt");
  7. BufferedReader br = new BufferedReader(fr);
  8. while (true)
  9. {
  10. String line = br.readLine();
  11. if (line == null)
  12. {
  13. Thread.sleep(1*1000);
  14. }
  15. else
  16. {
  17. byte[] y = line.getBytes();
  18. File g = new File("D:/abc.txt");
  19. OutputStream f = new FileOutputStream(g);
  20. f.write( y );
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement