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();
}
}
}
}
JAVA-IO流大文件拷贝的更多相关文章
- IO流大文件拷贝
String resourcesPath="f:/a.grd"; String targetPath=" ...
- 38、使用IO流进行文件拷贝
使用IO流进行文件拷贝 需求:在项目的根目录里面创建一个java.txt的文件,然后将这个文件拷贝到file文件夹里面并且重命名为good.txt文件先以流的方式将java.txt文件读取到内存中,然 ...
- Java:IO流与文件基础
Java:IO流与文件基础 说明: 本章内容将会持续更新,大家可以关注一下并给我提供建议,谢谢啦. 走进流 什么是流 流:从源到目的地的字节的有序序列. 在Java中,可以从其中读取一个字节序列的对象 ...
- java io流 对文件夹的操作
java io流 对文件夹的操作 检查文件夹是否存在 显示文件夹下面的文件 ....更多方法参考 http://www.cnblogs.com/phpyangbo/p/5965781.html ,与文 ...
- java io流 创建文件、写入数据、设置输出位置
java io流 创建文件 写入数据 改变system.out.print的输出位置 //创建文件 //写入数据 //改变system.out.print的输出位置 import java.io.*; ...
- java IO流 对文件操作的代码集合
Io流 按照分类 有两种分类 流向方向: 有输入流和输出流 按照操作类型有:字节流和字符流 按照流向方向 字节流的一些操作 //读文件 FileInputStream fis = new FileIn ...
- java IO流 Zip文件操作
一.简介 压缩流操作主要的三个类 ZipOutputStream.ZipFile.ZipInputStream ,经常可以看到各种压缩文件:zip.jar.GZ格式的压缩文件 二.ZipEntry ...
- java IO流之文件切割两例(含Properties 用法)
package cn.itcast.io.p1.splitfile; import java.io.File;import java.io.FileInputStream;import java.io ...
- java Io流更新文件内容
package com.hp.io; import java.io.FileOutputStream; import java.io.IOException; public class FileOut ...
- java io流 对文件操作
检查文件是否存在 获取文件路径 获取文件大小 ...... 更多参考手册 //对文件的操作 //检查文件是否存在 //获取文件路径 //获取文件大小 //文件是否可读 //文件是否可写 //.... ...
随机推荐
- MongoDB对数组元素及内嵌文档进行增删改查操作
比如我有一个user类,他包含一个标签属性,这个标签是一个数组,数组里面的元素是内嵌文档,格式如下: { "_id" : "195861", &qu ...
- python入门小结
以下划线开头的标识符是有特殊意义的.以单下划线开头(_foo)的代表不能直接访问的类属性,需通过类提供的接口进行访问,不能用"from xxx import *"而导入: 以双下划 ...
- PAT A1001 A+B Format (20 分)
AC代码 #include <cstdio> #include <algorithm> using namespace std; const int maxn = 11; in ...
- vue项目中实现图片懒加载的方法
对于图片过多的页面,为了加速页面加载速度,所以很多时候我们需要将页面内未出现在可视区域内的图片先不做加载, 等到滚动到可视区域后再去加载.这样子对于页面加载性能上会有很大的提升,也提高了用户体验. 实 ...
- python WordCloud 实现词云
简单示例 from matplotlib import pyplot as plt from wordcloud import WordCloud filename = "text.txt& ...
- [yii\queue\Queue] [10] unknown job (attempt: 1, PID: 31167) is finished with error: yii\base\ErrorException: unserialize(): Error at offset 1922 of 65535 bytes
网上的解决方案: 1. 报错场景:序列化字段中有中文,反序列化时有可能会出现报错. 错误原因:写入和取出数据库的时候,编码不同,中文符号长度不同,序列化中的长度就无法匹配. 解决办法:适合 php 5 ...
- centos php7 amqp
yum install -y librabbitmq-devel /home/git/php/bin/pecl install amqp echo "extension=amqp.so&qu ...
- How to mount remote windows partition (windows share) under Linux
http://www.cyberciti.biz/tips/how-to-mount-remote-windows-partition-windows-share-under-linux.html ...
- 02-【servlet】
1.什么是Servlet Servlet是JavaWeb的三大组件之一[Servlet,Filter,Listener],它属于动态资源.Servlet的作用是处理请求,服务器会把接收到的请求交给Se ...
- DNS负载均衡与NGINX负载均衡策略
负载均衡是指的是把请求均匀的分摊到多个服务器上处理.一般常见的负载均衡有两种:①客户端与反向代理服务器之间的DNS负载均衡②反向代理服务器与应用服务器之间的负载均衡(这种负载均衡有很多,可以是webl ...