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); } }
相关推荐
wifi 资料This presentation focuses on the specification, possible use cases and initial product certification test plan for Wi-Fi P2P technology
使用driect3D和C#实现用3D对象(x格式文件)的播放
Direct3D实现3维地形 有详细的注释 并能够实现自由漫游
可以更好的学Driect X!对于学生学习很有利!能让学Driect X更好地接受,了解!
DirectX12 (Windows 10提取版)
主要是一个简单视频播放器的源代码,主要用到win ce程序设计的知识,还有少量的driect show 的知识,希望对干开始编代码的人有所帮助,呵呵
rabbitMq中的driect模式,在服务端生产者可以直接使用此模式,对应消费端模式获取对接的模型消息,同时在生成的接口中可以直接使用此工具,方便适用!
//Don't Start Thread,Driect Communicate With Com Port,Please Use These Functions //不启动线程,直接与串口进行通信,请调用以下的函数 BOOL PS_CommInit(); BOOL PS_SendMessageToComm(char* szSendMsg,int ...
提供一個棋盤式的遊戲介面,提供基本Driect X Draw的操作方式
详细介绍了7号信令流程 ...D(Driect)链路:LSTP至HSTP之间的链路 E(Enhence)链路:本信令区STP与其他信令区的SP点间的链路 根据中国信令网络的特点,一般没有E链路。 F链路:SP点之间的直达信令链路
一.颜色表示: 二.顶点颜色 三.着色:
Directx input 源码 实现事件注册 硬件响应 现成库直接使用