2.改造入门案例


1.改造入门案例

import java.io.FileInputStream;
?
public class Dome01 {
   public static void main(String[] args) {
       FileInputStream fis = null;
       try {
           //创建字节输入流对象
           fis = new FileInputStream("d:/dome1.txt");
           StringBuilder strB = new StringBuilder();
           int temp = 0;
           while ((temp = fis.read()) != -1){
               System.out.println(temp);
               strB.append((char) temp);
          }
           System.out.println(strB);
      } catch (Exception e) {
           e.printStackTrace();
      } finally {
           //关闭IO流
           if (fis != null) {
               try {
                   fis.close();
              } catch (Exception e) {
                   e.printStackTrace();
              }
          }
      }
?
  }
}