Posted By

dalcacer on 03/09/10


Tagged

io copy binary


Versions (?)

Copy Bytes


 / Published in: Java
 

  1. import java.io.FileInputStream;
  2. import java.io.FileOutputStream;
  3. import java.io.IOException;
  4.  
  5. public class CopyBytes {
  6. public static void main(String[] args) throws IOException {
  7. FileInputStream in = null;
  8. FileOutputStream out = null;
  9. try {
  10. in = new FileInputStream("xanadu.txt");
  11. out = new FileOutputStream("outagain.txt");
  12. int c;
  13.  
  14. while ((c = in.read()) != -1) {
  15. out.write(c);
  16. }
  17.  
  18. } finally {
  19. if (in != null) {
  20. in.close();
  21. }
  22. if (out != null) {
  23. out.close();
  24. }
  25. }
  26. }
  27. }
  28.  

Report this snippet  

You need to login to post a comment.