import java.io.*; /* * edit.java * * Created on March 19, 2001, 12:48 AM */ /** * * @author esoto * @version */ public class edit extends VMachine { /** Creates new edit */ public edit() { } public void run() { RandomAccessFile editstream = null; try { String input = args[0]; if(input.compareTo("")==0) { sysapi.Write(OUT,"Please enter the file to edit: "); input = sysapi.Read(IN); } File editFile = new File(sysapi.findUser(owner).getcurrentPath() + input); editFile.createNewFile(); editstream = new RandomAccessFile(editFile,"rw"); sysapi.Write(OUT,"Editing file: " + input + "\n"); while(input.compareTo("")!=0) { input = sysapi.Read(IN); if(input.compareTo("")!=0) { editstream.writeBytes(input + "\n"); } } sysapi.Write(OUT,editFile.getName() + " saved.\n"); editstream.close(); } catch(Exception ex) { try { editstream.close(); } catch(IOException ioex) { System.out.println(ex); } System.out.println(ex); } sysapi.Exit(vmh,owner); } }