zoukankan      html  css  js  c++  java
  • IO流大文件拷贝

     1 package com.test.io;
     2 
     3 import java.io.BufferedInputStream;
     4 import java.io.BufferedOutputStream;
     5 import java.io.File;
     6 import java.io.FileInputStream;
     7 import java.io.FileOutputStream;
     8 import java.io.IOException;
     9 
    10 public class TestIO {
    11     private static int BUFFER_SIZE = 8192;
    12 
    13     public static void main(String[] args) throws IOException {
    14 
    15         String resourcesPath="f:/a.grd";
    16         String targetPath="d:/a.grd";
    17         File resourcesFile = new File(resourcesPath);
    18         File targetFile = new File(targetPath);
    19         BufferedInputStream input = new BufferedInputStream(new FileInputStream(resourcesFile));
    20         BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(targetFile));
    21         try {
    22             
    23             byte[] buffer = new byte[BUFFER_SIZE];
    24             int n = 0;
    25             while (-1 != (n = input.read(buffer, 0, BUFFER_SIZE))) {
    26                 output.write(buffer, 0, n);
    27             }
    28         } finally {
    29             if (input != null) {
    30                 input.close();
    31             }
    32             if (output != null) {
    33                 output.close();
    34             }
    35         }
    36     }
    37 }
  • 相关阅读:
    数组的拼接
    numpy的切片和索引
    细说python中的round()方法
    Numpy数组的创建
    快排 [随机数]
    对于归并排序递归的理解
    A1044 Shopping in Mars [连续子序列分割]
    A1085 Perfect Sequence [二分、two pointers]
    快速幂
    [转] 二分法求外接圆最大半径
  • 原文地址:https://www.cnblogs.com/bilaisheng/p/4976084.html
Copyright © 2011-2022 走看看