Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. import java.io.*;
  2.  
  3.  
  4. class IOUtilities {
  5.     public void copyInto(InputStream input, OutputStream output) throws FileNotFoundException, IOException
  6.     {
  7.         long size = ((FileInputStream)input).getChannel().size();
  8.  
  9.         for (long i = 0; i < size; i++)
  10.             output.write(input.read());
  11.  
  12.         output.close();
  13.         input.close();
  14.     }
  15.  
  16.     public void copyInto2(Reader input, Writer output) throws IOException
  17.     {
  18.         int b = input.read();
  19.  
  20.         while (b != -1)
  21.         {
  22.             output.write(b);
  23.             b = input.read();
  24.         }
  25.  
  26.         input.close();
  27.         output.close();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement