Guest User

Untitled

a guest
Apr 28th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.52 KB | None | 0 0
  1.     public static int save(byte[] bytes, File outputFile) throws IOException {
  2.         InputStream in = new ByteArrayInputStream(bytes);
  3.  
  4.         outputFile.getParentFile().mkdirs();
  5.         OutputStream out = new FileOutputStream(outputFile);
  6.  
  7.         try {
  8.             return IOUtils.copy(in, out);
  9.         } finally {
  10.             IOUtils.closeQuietly(in);
  11.             IOUtils.closeQuietly(out);
  12.            
  13.             // for Klocwork
  14.             try {
  15.                 out.close();
  16.             } catch (IOException ioe) {
  17.                 ioe.getMessage();
  18.             }
  19.             try {
  20.                 in.close();
  21.             } catch (IOException ioe) {
  22.                 ioe.getMessage();
  23.             }
  24.         }
  25.     }
Add Comment
Please, Sign In to add comment