当前位置:网站首页>NiO copy file call getchannel method transferfrom()
NiO copy file call getchannel method transferfrom()
2022-06-22 22:02:00 【kjshuan】
package kj15.niuzi.pojo;
import org.junit.Test;
import java.io.*;
import java.nio.channels.FileChannel;
public class Test01 {
@Test
public void test01() throws IOException {
FileInputStream ifo = new FileInputStream(new File("d:/abc"));
// Get file channel
FileChannel channel = ifo.getChannel();
FileOutputStream fos=new FileOutputStream(new File("d:/bcd"));
FileChannel channel1 = fos.getChannel();
// Copy file contents to another file
// call transferFrom Method
channel1.transferFrom(channel,0,channel.size());
// byte[] bts=new byte[ifo.available()]; //available() Method to get the size of the file
byte[] bts=new byte[1024];
// Traversal file
// Definition len Is the number of bytes read
int len=0;
while(ifo.read(bts)!=-1){
fos.write(bts);
}
//
//
// ifo.read(bts);
// fos.write(bts);
fos.close();
ifo.close();
}
}
边栏推荐
- Database summary: common problems and Optimization in MySQL development
- Ten thousand words long text | use RBAC to restrict access to kubernetes resources
- 分享insert into select遇到的死锁问题(项目实战)
- Redis核心技术与实战:学习总结目录
- HarmonyOS应用开发培训第二次
- ACM. HJ45 名字的漂亮度 ●●
- 牛客 52次月赛 C 说谎的机器 (区间赋值操作由O(n^2)转为O(n)的复杂度)
- ACM. The beauty of hj45 name ●●
- 万字长文 | 使用 RBAC 限制对 Kubernetes 资源的访问
- [icml2022] using virtual nodes to promote graph structure learning
猜你喜欢

杰理之开启四声道通话近端卡顿问题【篇】

7-9 super Mary

7-9 超级玛丽

(duc/ddc) digital up mixing / quadrature down mixing principle and MATLAB simulation

How to carry out encryption protection for equipment under extortion virus rampant
![Jerry's music mode obtains the directory of playing files [chapter]](/img/2f/efb8a077e3e398cb3b14cfd98a8422.png)
Jerry's music mode obtains the directory of playing files [chapter]

第030讲:文件系统:介绍一个高大上的东西 | 课后测试题及答案

300. longest increasing subsequence ●●

Redis usage scenario sharing (project practice)

引入稀疏激活机制!Uni-Perceiver-MoE显著提升通才模型的性能
随机推荐
LeetCode#20.有效的括号
Lesson 028: Documents: because I know you, I will never forget the after-school test questions and answers [no title]
An example of 89 Oracle SQL writing and optimizer defects
72 results and development suggestions of the latest on-site production system optimization
第027讲:集合:在我的世界里,你就是唯一 | 课后测试题及答案
IDC發布中國數據治理報告 億信華辰第一
Redis核心技术与实战:学习总结目录
ACM. Hj24 chorus ●●
[database] SQL Server quickly creates tables to simulate departments, courses, teachers, students and scores
(duc/ddc) digital up mixing / quadrature down mixing principle and MATLAB simulation
Oracle数据库中文字符串和英文字符串的截取不同
6-5 图的深度遍历-邻接矩阵实现
[records of different objects required by QIPA]
ACM. The beauty of hj45 name ●●
92 match for several_ Recognize SQL write example
引入稀疏激活机制!Uni-Perceiver-MoE显著提升通才模型的性能
Icml2022 | using virtual nodes to promote graph structure learning
LeetCode 每日一题——513. 找树左下角的值
The second harmonyos application development training
杰理之硬件上 DACL 输出,DAC 输出左右声道的声音【篇】