1 //read a file and print it on the screen
2 import java.io.*;
3
4 public class MyPrintStreamTest2{
5 public static void main(String[] args) {
6 String filename = args[0]; // firsttime to see!!!
7 if(filename!=null){ list(filename,System.out); }
8 }
9
10 public static void list(String filename,PrintStream ps){
11 try
12 {
13 BufferedReader br = new BufferedReader( new FileReader(filename) );
14 String s = null;
15 while ((s=br.readLine())!=null) {
16 ps.println(s);
17 }
18 br.close();
19 }
20
21 catch(IOException e)
22 {
23 ps.println("reading file error!");
24 }
25
26 }
27 }