zoukankan      html  css  js  c++  java
  • 太TM难看了,我自己都看不下去了

      继续研究文件IO。

      作用是用System.in输入一个文件路径,然后打印文件里的所有行。

      而且虽然没仔细检查过,哦不就是因为没检查过,所以肯定不够健壮。

     1 import java.io.*;
     2 import java.util.Scanner;
     3 
     4 public class test {
     5     public static void main(String[] args) {
     6         Scanner input = new Scanner(System.in);
     7         String file = input.nextLine();
     8         
     9         printContent(file, System.out);
    10     }
    11     
    12     public static void printContent(String file, PrintStream out) {
    13         try {
    14             BufferedReader input = new BufferedReader(new FileReader(file));
    15             
    16             String s = null;
    17             while ((s = input.readLine()) != null) {
    18                 out.println(s);
    19             }
    20         } catch (IOException e) {
    21             e.printStackTrace();
    22         }
    23     }
    24 }
    再说。太JB难看了……
  • 相关阅读:
    域对象
    会话
    http请求
    ServletContext对象的应用
    配置一个servlet程序
    合并两个有序数组
    删除排列数组中的重复项
    移除元素
    搜索插入位置
    九九乘法表
  • 原文地址:https://www.cnblogs.com/chihane/p/3472187.html
Copyright © 2011-2022 走看看