zoukankan      html  css  js  c++  java
  • [20160731]read a file and print it on the screen

     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 }
  • 相关阅读:
    Celery
    windows笔记目录
    Linux笔记目录
    python笔记目录
    rsa
    c#目录
    webpack3.x配置
    RabbitMQ服务安装(Linux)
    JavaScript验证用户输入
    IP地址检测工具
  • 原文地址:https://www.cnblogs.com/jasonzeng888/p/5722307.html
Copyright © 2011-2022 走看看