//FileOutputStream.java import java.io.*; public class FileInOutStreams { public static void main(String[] args) throws Exception { copyImage();} static void copyImage() { File src=new File("real.jpg"); read=new FileInputStream(src); File des=new File("java.jpg"); write=new FileOutputStream(des); int c,count=0; while((c=read.read()!=-1)) { write.write(c); count++; } System.out.print(count+"Byte Copied...."); } catch(FileNotFoundException ex) {ex.printStackTrace();} catch(IOException ex) {ex.printStackTrace();} try { read.close(); write.close(); } catch(IOException ex){ex.printStackTrace();} }
Output: Copied....