Driect-nonDricect 读取文件速度
来源:互联网 发布:知乎dota2 编辑:程序博客网 时间:2024/05/29 09:43
fos.write() 7965 ms
fileChannel.transferTo 170 ms
MappedByteBuffer out = fc.map(FileChannel.MapMode.READ_WRITE, 0, length); raf = new RandomAccessFile( metaFile, "rw" );FileChannel channel = raf.getChannel();channel.force( true );//強制將所有對此通道的檔案更新寫入包含該檔案的存儲設備中。如果此通道的檔案駐留在本地存儲設備上,則此方法返回時可保證,否则不保证。MappedByteBuffer buf = channel.map( FileChannel.MapMode.READ_WRITE, 0, metadataMaxLenght );
import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.RandomAccessFile;import java.nio.channels.FileChannel;public class TestFileChannel { public static void main( String[] args ) throws Exception { } public static void a() throws Exception{ File file = new File("d:/bcw-200.log"); FileInputStream fis = new FileInputStream( file ); File outFile = new File("d:/bcw-201.log"); FileOutputStream fos = new FileOutputStream( outFile ); int byteToRead = 1024; byte[] buff = new byte[byteToRead];// int byteRead = 0;// while(true){// int result = fis.read( bb, byteRead, byteToRead - byteRead );// if(result==-1){// break;// }// byteRead += result;// } long start = System.currentTimeMillis(); while(true){ int result = fis.read( buff ); fos.write( buff ); if(result == -1){ break; } } System.out.println(System.currentTimeMillis() - start); fis.close(); fos.close(); System.out.println(System.currentTimeMillis() - start); } public static void b() throws Exception{ File file = new File("d:/bcw-200.log"); FileInputStream fis = new FileInputStream( file ); File outFile = new File("d:/bcw-202.log"); FileOutputStream fos = new FileOutputStream( outFile ); FileChannel in = fis.getChannel(); FileChannel out = fos.getChannel(); long start = System.currentTimeMillis(); in.transferTo( 0, file.length(), out ); System.out.println(System.currentTimeMillis() - start); in.close(); out.close(); System.out.println(System.currentTimeMillis() - start); } public static void c() throws Exception{ File file = new File("d:/bcw-200.log"); FileInputStream fis = new FileInputStream( file ); File outFile = new File("d:/bcw-202.log"); FileOutputStream fos = new FileOutputStream( outFile ); FileChannel in = fis.getChannel(); FileChannel out = fos.getChannel(); RandomAccessFile raf = new RandomAccessFile( file, "rw" ); long start = System.currentTimeMillis(); in.transferTo( 0, file.length(), out ); System.out.println(System.currentTimeMillis() - start); in.close(); out.close(); System.out.println(System.currentTimeMillis() - start); }}
阅读全文
0 0
- Driect-nonDricect 读取文件速度
- CPP读取文件速度比较
- 文件(数据)读取速度
- CPP读取文件速度比较
- 怎样提高读取文件的速度?
- Scanner和BufferedReader读取文件速度比较
- ffmpeg读取文件速度的控制
- BufferedInputStream如何提高读取文件速度
- python 不同方式读取文件速度不同
- 0.driverbase-IRP、IO_STACK_LOCATION、文件三种读写方式(buffer/driect/other)、DeviceIoControl
- 关于数据库读取速度与文件IO读取速度的比较分析
- 使用内存映射文件加快读取大文件的速度 .
- Wifi-Driect过程
- java:经典文件写入和读取,速度超快
- java:经典文件写入和读取,速度超快
- java:经典文件写入和读取,速度超快
- java NIO/IO文件读取+md5校验速度对比
- IO读取速度测试
- NOIP模拟 01祖玛【区间dp】
- mongodb 分组 得到第一条数据
- 读书笔记(1)深入理解计算机系统
- mongodb 导入导出 csv
- 简述 运行时异常RunTimeException和检查性异常Checked Exception
- Driect-nonDricect 读取文件速度
- centos yum 安装 高版本 mysql(5.5)
- [最小基环生成树] Codeforces875F .Royal Questions
- linux centos 安装 源码安装 mysql 5.6
- 实验--线程安全(1)ArrayList
- mongoVUE 用_id查找
- linux步步为营(7)--awk--xargs
- centos 安装 java7,tomcat7,mysql5.6,mongodb
- IoBuffer的wrap,rewind的使用