Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import java.io.FileInputStream;
  2. import java.io.FileOutputStream;
  3. import java.io.IOException;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JOptionPane;
  7.  
  8. public class Main {
  9. public static void main(String[] args) throws IOException, InterruptedException {
  10.  
  11. ProcessBuilder p = new ProcessBuilder();
  12.  
  13. p.command("notepad.exe", "D:\\zapisy.txt");
  14.  
  15.  
  16. FileInputStream fis=new FileInputStream("D:\\zapiswlaczony.txt");
  17. int a=fis.read();
  18. fis.close();
  19. if((char)a=='0')
  20. {
  21. FileOutputStream fos=new FileOutputStream("D:\\zapiswlaczony.txt");
  22. fos.write('1');
  23. fos.close();
  24. Process notepad = p.start();
  25. System.out.println("Start");
  26.  
  27. while(notepad.isAlive())
  28. {
  29.  
  30.  
  31. }
  32. notepad.destroyForcibly();
  33. FileOutputStream fos2=new FileOutputStream("D:\\zapiswlaczony.txt");
  34. fos2.write('0');
  35. System.out.println("End");
  36. }
  37. else
  38. {
  39. JFrame frame = new JFrame("Informacja");
  40. JOptionPane.showMessageDialog(frame, "Zapis jest używany");
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement