日期:2014-05-16 浏览次数:20906 次
package com.test; import java.io.FileOutputStream; import java.io.RandomAccessFile; public class Test { /** * @param args */ public static void main(String[] args) throws Exception { RandomAccessFile randomAccessFile = new RandomAccessFile("c:\\a.rar", "r"); // System.out.println(randomAccessFile.length()); // randomAccessFile.skipBytes(1000); // randomAccessFile.skipBytes(1000); FileOutputStream outputStream = new FileOutputStream("c:\\b.rar"); byte[] b = new byte[1024]; int i = -1; while ((i = randomAccessFile.read(b, 0, b.length)) != -1) { System.out.println(randomAccessFile.getFilePointer()); outputStream.write(b, 0, i); // randomAccessFile.skipBytes(1024); } outputStream.close(); randomAccessFile.close(); } }