Advertisement
Guest User

Untitled

a guest
May 26th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package Server;
  2.  
  3. import java.io.Closeable;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.OutputStream;
  7.  
  8.  
  9. public class FileUtils
  10. {
  11. private final static int BUFFER_SIZE = 16 * 1024;
  12.  
  13. public static void copyStream(InputStream in, OutputStream out)
  14. throws IOException
  15. {
  16. try
  17. {
  18. byte [] buffer = new byte[BUFFER_SIZE];
  19. int count = -1;
  20. while ((count = in.read(buffer)) >= 0)
  21. {
  22. out.write(buffer, 0, count);
  23. }
  24. }
  25. finally
  26. {
  27. close(in);
  28. close(out);
  29. }
  30. }
  31.  
  32. public static void close(Closeable obj)
  33. {
  34. try
  35. {
  36. obj.close();
  37. }
  38. catch (IOException e)
  39. {
  40. e.printStackTrace();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement