zoukankan      html  css  js  c++  java
  • FileInputStream FileOutputStream

    FileInputStream is a stream to grab the information from files.Combined with FileOutputStream, we can achieve the function of copying.

    Examples:

    public class Demo4 {
     
     public static void main(String[] args) {
      String content = null;
      byte[] buffer = new byte[1024];
      int size = 0;
      File file = new File("C:/Users/caich5/Desktop/aaaa.txt");
      InputStream input = null;
      try {
          input = new FileInputStream(file);
          OutputStream output = new FileOutputStream("C:/Users/caich5/Desktop/tttd.txt");
       while((size = input.read(buffer))!= -1){
        //show in console
        content = new String(buffer,0,size);
        System.out.println(content);
        //copy to another file
        output.write(buffer, 0, size);
       }
       input.close();
      } catch (Exception e) {
       e.printStackTrace();
      }
     }
    }

    Tips: FileInputStream,FileOutputStream,both of them are low lever stream.

    Aimer,c'est partager
  • 相关阅读:
    python https请求报错:SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]
    python打包为exe文件
    文件自定义扫描工具
    pandas 的常用方法
    cisco应用
    Cisco 模拟配置
    python 识别图片上的数字
    OpenSSL
    OpenSSL
    OpenSSL
  • 原文地址:https://www.cnblogs.com/pickKnow/p/8512493.html
Copyright © 2011-2022 走看看