/** * Copy stream-data from source to destination, with buffering. This is * equivalent to passing {@link #copy}a * <code>java.io.BufferedInputStream</code> and * <code>java.io.BufferedOutputStream</code> to {@link #copy}, and * flushing the output stream afterwards. The streams are not closed after * the copy. * * @param source The InputStream to obtain data from. * @param destination The OutputStream to copy data to. * @throws IOException if IO error */ public static void bufferedCopy(final InputStream source, final OutputStream destination) throws IOException { final BufferedInputStream input = new BufferedInputStream(source); final BufferedOutputStream output = new BufferedOutputStream( destination); copy(input, output); output.flush(); }
protected byte[] getBytesFromBitstream(Context context, Item item, String bitstream_name) throws SQLException, IOException, AuthorizeException { Bitstream bs = getBitstream(item, bitstream_name); // no such bitstream if (bs == null) { return null; } // create a ByteArrayOutputStream ByteArrayOutputStream baos = new ByteArrayOutputStream(); Utils.copy(bitstreamService.retrieve(context, bs), baos); return baos.toByteArray(); }
@Override public void ingest(Context context, DSpaceObject dso, InputStream in, String MIMEType) throws CrosswalkException, IOException, SQLException, AuthorizeException { // If package includes a Creative Commons license, add that: if (dso.getType() == Constants.ITEM) { if (log.isDebugEnabled()) { log.debug("Reading a DSpace Deposit license, MIMEtype=" + MIMEType); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); Utils.copy(in, baos); PackageUtils.addDepositLicense(context, baos.toString(), (Item) dso, null); } }
@Override public void disseminate(Context context, DSpaceObject dso, OutputStream out) throws CrosswalkException, IOException, SQLException, AuthorizeException { if (dso.getType() == Constants.ITEM) { Bitstream licenseBs = PackageUtils.findDepositLicense(context, (Item) dso); if (licenseBs != null) { Utils.copy(bitstreamService.retrieve(context, licenseBs), out); out.close(); } } }
@Override public void disseminate(Context context, DSpaceObject dso, OutputStream out) throws CrosswalkException, IOException, SQLException, AuthorizeException { if (dso.getType() == Constants.ITEM) { Bitstream cc = creativeCommonsService.getLicenseRdfBitstream((Item) dso); if (cc != null) { Utils.copy(bitstreamService.retrieve(context, cc), out); out.close(); } } }
@Override public void disseminate(Context context, DSpaceObject dso, OutputStream out) throws CrosswalkException, IOException, SQLException, AuthorizeException { if (dso.getType() == Constants.ITEM) { Bitstream cc = creativeCommonsService.getLicenseTextBitstream((Item) dso); if (cc != null) { Utils.copy(bitstreamService.retrieve(context, cc), out); out.close(); } } }
OutputStream fos = new BufferedOutputStream( new FileOutputStream(packageFile)); Utils.copy(is, fos); fos.close(); is.close();
OutputStream fos = new BufferedOutputStream( new FileOutputStream(packageFile)); Utils.copy(is, fos); fos.close(); is.close();
Utils.copy(is, fos); fos.close(); is.close();
OutputStream fos = new BufferedOutputStream( new FileOutputStream(packageFile)); Utils.copy(is, fos); fos.close(); is.close();
InputStream is = bitstreamService .retrieve(context, bitstream); Utils.copy(is, zip); zip.closeEntry(); is.close();
Utils.copy(bitstreamService.retrieve(context, pkgBs), out); } finally { if (out != null) {
Utils.copy(is, zip); zip.closeEntry();