protected Properties getProperties() { Properties p = new Properties(); FileInputStream fis = null; try { fis = new FileInputStream(file); p.load(fis); return p; } catch (Exception e) { throw new RuntimeException("Could not read file: " + file); } finally { Utils.closeQuietly(fis); } }
/** * Return byte array of Thumbnail, providing byte array * * @param thumbnail * @param buf * @return a byte array * @throws IOException */ public byte[] getThumbnail(Thumbnail thumbnail, byte[] buf) throws IOException { String path = getThumbnailPath(thumbnail.getId()); FileInputStream stream = new FileInputStream(path); try { stream.read(buf, 0, buf.length); } finally { Utils.closeQuietly(stream); } return buf; }
set(null, ex); } finally { Utils.closeQuietly(bufIn);
public void download(long fileId, File file, int blockSize) throws ServerError, IOException { final ServiceFactoryPrx sf = getSession(); final OriginalFile obj = (OriginalFile) sf.getQueryService().get("OriginalFile", fileId); final RawFileStorePrx store = sf.createRawFileStore(); final FileOutputStream stream = new FileOutputStream(file); final long size = obj.getSize().getValue(); long offset = 0; store.setFileId(fileId); try { for (offset = 0; (offset+blockSize) < size;) { stream.write(store.read(offset, blockSize)); offset += blockSize; } stream.write(store.read(offset, (int) (size-offset))); } finally { Utils.closeQuietly(stream); store.close(); } }
Utils.closeQuietly(stream); if (rfs != null) { rfs.close();