Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void copyFile(String fileName, InputStream in) {
  2.         try {
  3.             OutputStream out = new FileOutputStream(new File(imagesPath + fileName));
  4.  
  5.             IOUtils.copy(in, out);
  6.  
  7.             BufferedImage originalImage = ImageIO.read(new File(imagesPath + fileName));
  8.             if (originalImage.getHeight() > HEIGHT && originalImage.getWidth() > WIDTH) {
  9.                 Thumbnails.of(originalImage).size(WIDTH, HEIGHT).toFile(imagesPath + fileName);
  10.             }
  11.  
  12.             in.close();
  13.             out.flush();
  14.             out.close();
  15.  
  16.             MessageUtil.addInfoMessage(GLOBAL_MSG_UPLOAD);
  17.         } catch (IOException e) {
  18.             MessageUtil.addErrorMessage(GLOBAL_MSG_ERRO);
  19.             e.printStackTrace();
  20.             LOGGER.error(e.getMessage());
  21.         }
  22.     }