zoukankan      html  css  js  c++  java
  • 文件复制三种方法

           File f = new File("d:\\ibatis.log");
            File f1 = new File("d:\\ibatis2.log");
            byte b[] = new byte[1024];
            int l = 0;
            char c[] = new char[1024];
            String str = "";
            try
            {
                /**
                 * 文件复制方法1
                 */
                FileInputStream fis = new FileInputStream(f);
                FileOutputStream fos = new FileOutputStream(f1);
                while ((l = fis.read(b)) > 0)
                {
                    fos.write(b);
                }
                /**
                 * 文件复制方法2
                 */
                FileReader fr = new FileReader(f);
                FileWriter fw = new FileWriter(f1);
                
                while ((l = fr.read(c)) > 0)
                {
                    fw.write(c);
                }
                /**
                 * 文件复制方法3
                 */
                BufferedReader br = new BufferedReader(new InputStreamReader(fis));
                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
                while ((str = br.readLine()) != null)
                {
                    bw.write(str);
                }
                
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
  • 相关阅读:
    python百度ai的银行卡识别代码
    python百度ai的身份证识别代码
    Linux下安装jupyter
    HADOOP 与 jupyterlab 链接
    csv文件数据导出到mongo数据库
    Contos7 常用命令
    centos 安装Python3 及对应的pip
    PHP 连接数据库
    java 注解学习记录
    java简单实现搜索指定后缀文件
  • 原文地址:https://www.cnblogs.com/lishoubin/p/3211304.html
Copyright © 2011-2022 走看看