Util
程序员文章站
2022-05-26 14:06:00
...
NioCopy
public static void nioCopyFile(String resource,String destination)
throws Exception{
FileInputStream fis = new FileInputStream(resource);
FileOutputStream fos = new FileOutputStream(destination);
//得到readChannel
FileChannel readChannel = fis.getChannel();
//得到writeChannel
FileChannel writeChannel = fos.getChannel();
ByteBuffer buffer = ByteBuffer.allocate(1024);
while(true){
buffer.clear();
int len = readChannel.read(buffer);
if(len==-1){
break;
}
buffer.flip();//read--->write
writeChannel.write(buffer);
}
readChannel.close();
writeChannel.close();
}
上一篇: Vim编辑器
下一篇: 【代码】批量 CSV转SHP
推荐阅读
-
Java中数组操作 java.util.Arrays 类常用方法的使用
-
Java日志介绍(1)-java.util.logging.Logger
-
net core WebApi——April.Util更新之权限
-
tomact正常启动,但是在日志文件报错java.lang.NoClassDefFoundError: java/util/logging/Logger
-
httpclient的工具类util
-
win7上代码连接hadoop出现错误 :org.apache.hadoop.util.NativeCrc32.nativeComputeChunkedSumsByteArray(II[BI[BIILjava/lang/String;JZ)V
-
util.Date与sql.Date转换
-
mybatis报错: java.lang.IllegalArgumentException invalid comparison: java.util.Date and java.lang.String
-
tomcat启动maven项目报错 提示:java.util.concurrent.executionexception:org.apache.catalina.lifecyleexception:
-
Tomcat启动报错:org.apache.catalina.LifecycleException: Failed to start component...java.util.zip.ZipException: error in opening zip file