当前位置:网站首页>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();
}
}
边栏推荐
- [513. find the value in the lower left corner of the tree]
- Linux安装Mysql(包成功!!)
- Lesson 022: function: recursion is god horse after class test questions and answers
- 第029讲:文件:一个任务 | 课后测试题及答案
- [database] SQL Server quickly creates tables to simulate departments, courses, teachers, students and scores
- The interception of Chinese and English strings in Oracle database is different
- [records of different objects required by QIPA]
- Introduce sparse activation mechanism! Uni perceiver MOE significantly improves the performance of generalist model
- (duc/ddc) digital up mixing / quadrature down mixing principle and MATLAB simulation
- Is data scientist a promising profession?
猜你喜欢

Implementation of breadth traversal adjacency matrix of 6-6 graph

For an unforgettable memory: special topic of Sun Jian

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

科研热点|官宣!2022年JCR分区和影响因子发布时间确定!
![[records of different objects required by QIPA]](/img/f7/c0f0f56e4f1bf4f1a0a61552afcd2b.png)
[records of different objects required by QIPA]
![Jerry's problem of opening the near end of four channel call [chapter]](/img/54/d74a90e37deb2d3929f019d695f9ee.png)
Jerry's problem of opening the near end of four channel call [chapter]
[database] SQL Server quickly creates tables to simulate departments, courses, teachers, students and scores

CYCA少儿形体礼仪 深圳市培训成果考核圆满落幕

What is a data asset? How should data asset management be implemented?

7-1 前序序列创建二叉树
随机推荐
79- do not create desc descending index when you see order by XXX desc - there is book donation benefit at the end of the article
ACM. HJ45 名字的漂亮度 ●●
第030讲:文件系统:介绍一个高大上的东西 | 课后测试题及答案
Implementation of breadth traversal adjacency matrix of 6-6 graph
Linux安装Mysql(包成功!!)
Redis usage scenario sharing (project practice)
CVPR2022 | 用于重采图像的特征解耦学习与动态融合
6月25日PMI认证考点防疫要求及考场安排
2022年朝阳区科技创新课之“产品创新与成果转化”训练营活动圆满结束
TC397 Flash
杰理之列免晶振一拖八烧录升级【篇】
How to operate redis on the IntelliJ idea database console
Differences between watch, computed and methods
ACM. Hj24 chorus ●●
科研热点|官宣!2022年JCR分区和影响因子发布时间确定!
71- analysis of an Oracle DBA interview with Alibaba in 2010
Lesson 030: file system: introduce a big thing | after class test questions and answers
6-1 operation set of binary search tree
VS代码一键整理快捷键
Ten thousand words long text | use RBAC to restrict access to kubernetes resources