/*Used to output a text file*/ import java.lang.*; import java.util.*; import java.io.*; public class cat extends VirtualMachine { public cat()throws IOException { // in = new BufferedReader(new InputStreamReader(System.in)); } public cat(String filename)throws IOException { File f= new File(System.getProperty("user.dir"),filename); in = new BufferedReader(new FileReader(f)); } public cat(String arg, String filename )throws IOException { if( !arg.equals("-n")) { System.out.println("Invalid arguments supplied "+arg); throw (new IOException()); } flag = true; File f= new File(System.getProperty("user.dir"),filename); in = new BufferedReader(new FileReader(f)); } public void run(){ print(); } synchronized void print() { String temp; try { String line; int i=0; while ((line = ((BufferedReader)in).readLine()) != null) { if( (int)line.charAt(0) ==24 ) { ((BufferedWriter)out).newLine(); break; } if(flag) { temp = " "+(++i)+": "; ((BufferedWriter)out).write(temp.toCharArray()); ((BufferedWriter)out).write(line.toCharArray()); ((BufferedWriter)out).newLine(); ((BufferedWriter)out).flush(); } } } catch(Exception E) { } } private boolean flag= false; int id; }