// This example program by max@gac.edu reads in a file, one line at // a time, and outputs each line to the standard output (i.e., the // terminal display unless you have redirected standard output). That // is, if you put this into OutputFile.java, and compile it with // javac, you could then execute // // java OutputFile somefilename // // to display the contents of the file named "somefilename", assuming you // have such a file. For example, you could execute // // java OutputFile OutputFile.java // // to use the program to display its own source code. import java.io.*; public class OutputFile { public static void main(String argv[]) throws Exception { String line; BufferedReader inFromFile = new BufferedReader (new InputStreamReader(new FileInputStream(argv[0]))); while((line = inFromFile.readLine()) != null){ System.out.println(line); } inFromFile.close(); } }