Advertisement
Nik

Shitty code example

Nik
May 17th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.05 KB | None | 0 0
  1.     private static void copyFile(URL sourceURL, String destFileName)
  2.             throws IOException {
  3.         File destFile = new File(destFileName);
  4.         File destDirectory = destFile.getParentFile();
  5.         destDirectory.mkdirs();
  6.         InputStream srcStream = sourceURL.openStream();
  7.         try {
  8.             OutputStream destStream = new FileOutputStream(destFile);
  9.             try {
  10.                 copyStreams(srcStream, destStream);
  11.             } finally {
  12.                 destStream.close();
  13.             }
  14.         } finally {
  15.             srcStream.close();
  16.         }
  17.     }
  18.  
  19. ===============================================================================================
  20.  
  21.     private static void copyFile(URL sourceURL, String destFileName) throws IOException
  22.     {
  23.         File destFile = new File(destFileName);
  24.         File destDirectory = destFile.getParentFile();
  25.         destDirectory.mkdirs();
  26.         InputStream srcStream = sourceURL.openStream();
  27.         try
  28.         {
  29.             OutputStream destStream = new FileOutputStream(destFile);
  30.             try
  31.             {
  32.                 copyStreams(srcStream, destStream);
  33.             }
  34.             finally
  35.             {
  36.                 destStream.close();
  37.             }
  38.         }
  39.         finally
  40.         {
  41.             srcStream.close();
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement