http://www.verejava.com/?id=16994711024818
package com.randomaccessfile; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.RandomAccessFile; public class TestDownload { public static void main(String[] args) { try { InputStream is=new FileInputStream(new File("res/raf/water.jpg")); RandomAccessFile raf=new RandomAccessFile(new File("res/raf/new.jpg"),"rw"); int l=0; while((l=is.read())!=-1) { raf.write(l); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
http://www.verejava.com/?id=16994711024818