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 }
  • 相关阅读:
    数据结构—堆排序
    关于《数据结构》课本KMP算法的理解
    KMP字符串匹配算法
    POJ 3784 Running Median(动态维护中位数)
    C++ STL 全排列
    数据结构——哈夫曼(Huffman)树+哈夫曼编码
    算法与数据结构实验6:逆序对(归并排序)
    C++ STL 优先队列 priority_queue 详解(转)
    现在和未来
    Karen and Coffee CF 816B(前缀和)
  • 原文地址:https://www.cnblogs.com/bilaisheng/p/4976084.html
Copyright © 2011-2022 走看看