org.dspace.core.Utils.copy()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.dspace.core.Utils.copy()方法的一些代码示例,展示了Utils.copy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.copy()方法的具体详情如下:
包路径:org.dspace.core.Utils
类名称:Utils
方法名:copy

Utils.copy介绍

[英]Copy stream-data from source to destination. This method does not buffer, flush or close the streams, as to do so would require making non-portable assumptions about the streams' origin and further use. If you wish to perform a buffered copy, use #bufferedCopy.
[中]将流数据从源复制到目标。这种方法不会缓冲、冲洗或关闭流,因为这样做需要对流的来源和进一步使用做出不可移植的假设。如果希望执行缓冲复制,请使用#bufferedCopy。

代码示例

代码示例来源:origin: DSpace/DSpace

/**
 * 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();
}

代码示例来源:origin: DSpace/DSpace

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();
}

代码示例来源:origin: DSpace/DSpace

@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);
  }
}

代码示例来源:origin: DSpace/DSpace

@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();
    }
  }
}

代码示例来源:origin: DSpace/DSpace

@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();
    }
  }
}

代码示例来源:origin: DSpace/DSpace

@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();
    }
  }
}

代码示例来源:origin: DSpace/DSpace

OutputStream fos = new BufferedOutputStream(
  new FileOutputStream(packageFile));
Utils.copy(is, fos);
fos.close();
is.close();

代码示例来源:origin: DSpace/DSpace

OutputStream fos = new BufferedOutputStream(
  new FileOutputStream(packageFile));
Utils.copy(is, fos);
fos.close();
is.close();

代码示例来源:origin: org.dspace/dspace-sword-api

Utils.copy(is, fos);
fos.close();
is.close();

代码示例来源:origin: DSpace/DSpace

OutputStream fos = new BufferedOutputStream(
  new FileOutputStream(packageFile));
Utils.copy(is, fos);
fos.close();
is.close();

代码示例来源:origin: DSpace/DSpace

InputStream is = bitstreamService
  .retrieve(context, bitstream);
Utils.copy(is, zip);
zip.closeEntry();
is.close();

代码示例来源:origin: DSpace/DSpace

Utils.copy(bitstreamService.retrieve(context, pkgBs), out);
} finally {
  if (out != null) {

代码示例来源:origin: DSpace/DSpace

if (auth) {
        InputStream input = bitstreamService.retrieve(context, bitstream);
        Utils.copy(input, zip);
        input.close();
      } else {
Utils.copy(bitstreamService.retrieve(context, logoBs), zip);
zip.closeEntry();

代码示例来源:origin: DSpace/DSpace

Utils.copy(is, zip);
zip.closeEntry();

相关文章

微信公众号

最新文章

更多