Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- public class Main {
- public static void main(String[] args) throws IOException, InterruptedException {
- ProcessBuilder p = new ProcessBuilder();
- p.command("notepad.exe", "D:\\zapisy.txt");
- FileInputStream fis=new FileInputStream("D:\\zapiswlaczony.txt");
- int a=fis.read();
- fis.close();
- if((char)a=='0')
- {
- FileOutputStream fos=new FileOutputStream("D:\\zapiswlaczony.txt");
- fos.write('1');
- fos.close();
- Process notepad = p.start();
- System.out.println("Start");
- while(notepad.isAlive())
- {
- }
- notepad.destroyForcibly();
- FileOutputStream fos2=new FileOutputStream("D:\\zapiswlaczony.txt");
- fos2.write('0');
- System.out.println("End");
- }
- else
- {
- JFrame frame = new JFrame("Informacja");
- JOptionPane.showMessageDialog(frame, "Zapis jest używany");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement