JAVA IO流中常用节点流程序示列

public  static void main1()throws IOException{
    
    
  FileInputStream fileInputStream = new FileInputStream("");
  byte[] buffer = new byte[1024];
  int hasRead = 0;
  while((hasRead = fileInputStream.read(buffer)) > 0){
    
    
   System.out.print(new String(buffer, 0, hasRead));
  }
  fileInputStream.close();
 }
 public static void main2()throws IOException{
    
    
  FileReader fileReader = new FileReader("");
  char[] buffer = new char[32];
  int hasRead = 0;
  while((hasRead = fileReader.read(buffer)) > 0){
    
    
   System.out.print(new String(buffer, 0, hasRead));
  }
  fileReader.close();
 }
 public static  void main3()throws IOException{
    
    
  FileInputStream fileInputStream = new FileInputStream("");
  FileOutputStream fileOutputStream = new FileOutputStream("");
  byte[] buffer = new byte[1024];
  int hasRead = 0;
  while((hasRead  = fileInputStream.read(buffer)) > 0){
    
    
   fileOutputStream.write(buffer, 0, hasRead);
  }
  fileInputStream.close();
  fileOutputStream.close();
 }

猜你喜欢

转载自blog.csdn.net/weixin_44703894/article/details/109844465