[20160731]read a file and print it on the screen

 //read a file and print it on the screen
import java.io.*; public class MyPrintStreamTest2{
public static void main(String[] args) {
String filename = args[0]; // firsttime to see!!!
if(filename!=null){ list(filename,System.out); }
} public static void list(String filename,PrintStream ps){
try
{
BufferedReader br = new BufferedReader( new FileReader(filename) );
String s = null;
while ((s=br.readLine())!=null) {
ps.println(s);
}
br.close();
} catch(IOException e)
{
ps.println("reading file error!");
} }
}
上一篇:[BZOJ 3167][HEOI 2013]SAO


下一篇:Microsoft office2010页码设置----论文、课程设计报告格式