锁定老帖子 主题:高效的RandomAccessFile
该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2012-05-29
若是这样效率会更高
RandomAccessFile rafr,rafw; rafr = new RandomAccessFile("F:\\ha.rar", "r"); rafw = new RandomAccessFile(".\\004.rar", "rw"); byte[] buffer=new byte[1024]; start = System.currentTimeMillis(); while((readcount = rafr.read(buffer)) != -1) { rafw.write(buffer, 0, readcount); } rafr.close(); rafw.close(); System.out.println("RandomAccessFile Copy & Write File: " + brafReadFile.filename + " FileSize: " + java.lang.Integer.toString((int)readfilelen >> 1024) + " (KB) " + "Spend: " + (double)(System.currentTimeMillis()-start) / 1000 + "(s)"); |
|
返回顶楼 | |