Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. BufferedInputStream input = null;
  2. BufferedOutputStream output = null;
  3. try{
  4. input = new BufferedInputStream(new FileInputStream("data.txt"));
  5. output = new BufferedOutputStream(new FileOutputStream("newdata.txt"));
  6.  
  7. for(int i = input.read(); i != -1; i = input.read()){
  8. output.write(i);
  9. System.out.println();
  10. }
  11. //Flush in case the buffer doesn't fill up when done
  12. output.flush();
  13.  
  14. }catch (IOException ex){
  15. System.out.println();
  16. }finally {
  17. try{
  18. if (input != null){
  19. input.close(); //Closes both the
  20. }
  21. if (output != null){
  22. output.close(); //Closes both the
  23. }
  24. }catch (IOException ex){
  25. System.out.println(ex);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement