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 }
  • 相关阅读:
    iOS-深入理解(转载)
    iOS开发
    夜光遥感
    希尔伯特曲线在地图图像分割中的应用
    希尔伯特曲线
    NLP生成论文
    MapGIS SDK(C++)【基础篇】
    从npm到vue和nodejs
    分形在遥感和GIS中的应用
    MapReduce、Hadoop、PostgreSQL、Spark
  • 原文地址:https://www.cnblogs.com/bilaisheng/p/4976084.html
Copyright © 2011-2022 走看看