• JAVA-IO流大文件拷贝


    package com.test.io;
    
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    public class TestIO {
        private static int BUFFER_SIZE = 8192;
    
        public static void main(String[] args) throws IOException {
            // 该文件10G 以上
            String resourcesPath="f:/a.grd";
            String targetPath="d:/a.grd";
            File resourcesFile = new File(resourcesPath);
            File targetFile = new File(targetPath);
            BufferedInputStream input = new BufferedInputStream(new FileInputStream(resourcesFile));
            BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(targetFile));
            try {
    
                byte[] buffer = new byte[BUFFER_SIZE];
                int n = 0;
                while (-1 != (n = input.read(buffer, 0, BUFFER_SIZE))) {
                    output.write(buffer, 0, n);
                }
            } finally {
                if (output != null) {
                    output.close();
                }
                if (input != null) {
                    input.close();
                }
    
            }
        }
    }
  • 相关阅读:
    test20180922 倾斜的线
    test20180921 量子纠缠
    test20180921 手机信号
    test20180919 选择客栈
    BZOJ3083 遥远的国度
    test20180907 day1
    [ZJOI2010]基站选址
    HDU3584 Cube
    POJ2155 Matrix
    test20180902 day1
  • 原文地址:https://www.cnblogs.com/bilaisheng/p/10211052.html
Copyright © 2020-2023  润新知