SHARE
TWEET

Untitled

a guest Oct 16th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top