Java 类org.apache.commons.io.input.AutoCloseInputStream 实例源码

项目:AwesomeJavaLibraryExamples    文件:ExampleAddImage.java   
private static void createFinalDocument(File pdfFile, File overlayPdf) throws IOException
{
   PDDocument doc = new PDDocument();

   try
   {
      PDPage page = new PDPage();

      doc.addPage(page);
      PDImageXObject pdImage =JPEGFactory.createFromStream(doc, new AutoCloseInputStream(ExampleAddImage.class.getClassLoader().getResourceAsStream("death-star-plans.jpg")));
      PDPageContentStream contentStream = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND, true);
      Map<Integer, String> overlayGuide = new HashMap<>();

      contentStream.drawImage(pdImage, 100, 300, pdImage.getWidth()*scale, pdImage.getHeight()*scale);

      overlayGuide.put(1, overlayPdf.getAbsolutePath());
      Overlay overlay = new Overlay();
      overlay.setInputPDF(doc);
      overlay.setOverlayPosition(Overlay.Position.FOREGROUND);
      overlay.overlay(overlayGuide);

      contentStream.close();
      doc.save(pdfFile);
   }
   finally
   {
      doc.close();
   }
}
项目:artifactory    文件:BintrayServiceImpl.java   
private void pushArtifactsToVersion(BintrayUploadInfo uploadInfo, List<FileInfo> artifactsToPush,
        BasicStatusHolder status, VersionHandle bintrayVersionHandle) throws MultipleBintrayCallException {
    List<RepoPath> artifactPaths = Lists.newArrayList();
    Map<String, InputStream> streamMap = Maps.newHashMap();
    try {
        for (FileInfo fileInfo : artifactsToPush) {
            artifactPaths.add(fileInfo.getRepoPath());
            ResourceStreamHandle handle = repoService.getResourceStreamHandle(fileInfo.getRepoPath());
            streamMap.put(fileInfo.getRelPath(), new AutoCloseInputStream(handle.getInputStream()));
        }
        status.status("Starting to push the requested files to " + String.format("into %s/%s/%s/%s: ",
                uploadInfo.getPackageDetails().getSubject(), uploadInfo.getPackageDetails().getRepo(),
                uploadInfo.getPackageDetails().getName(), uploadInfo.getVersionDetails().getName()), log);

        log.info("Pushing {} files...", streamMap.keySet().size());
        log.debug("Pushing the following files into Bintray: {}", Arrays.toString(artifactPaths.toArray()));
        bintrayVersionHandle.upload(streamMap);
    } catch (MultipleBintrayCallException mbce) {
        for (BintrayCallException bce : mbce.getExceptions()) {
            status.error(bce.toString(), bce.getStatusCode(), log);
        }
        throw mbce;
    } finally {
        for (InputStream stream : streamMap.values()) {
            IOUtils.closeQuietly(stream);
        }
    }
}
项目:swampmachine    文件:SimpleFileReader.java   
@Override
public InputStream getFileAsStream(Path file) throws IOException {
    InputStream in = new FileInputStream(file.toFile());
    BufferedInputStream bis = new BufferedInputStream(in);
    AutoCloseInputStream acis = new AutoCloseInputStream (bis);

    return acis;
}
项目:Pure-File-Manager    文件:CommandLineFileTest.java   
private String md5sum(final File file) {
    try {
        final InputStream fis = new AutoCloseInputStream(new FileInputStream(file));
        return new String(Hex.encodeHex(DigestUtils.md5(fis)));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:caarray    文件:FilesystemDataStorage.java   
/**
 * {@inheritDoc}
 */
@Override
public InputStream openInputStream(URI handle, boolean compressed) throws DataStoreException {
    checkScheme(handle);
    try {
        return new AutoCloseInputStream(FileUtils.openInputStream(openFile(handle, compressed)));
    } catch (final IOException e) {
        throw new DataStoreException("Could not open input stream for data: ", e);
    }
}
项目:caarray    文件:DatabaseMultipartBlobDataStorage.java   
/**
 * {@inheritDoc}
 */
@Override
public InputStream openInputStream(URI handle, boolean compressed) throws DataStoreException {
    checkScheme(handle);
    try {
        return new AutoCloseInputStream(FileUtils.openInputStream(openFile(handle, compressed)));
    } catch (final IOException e) {
        throw new DataStoreException("Could not open input stream for data: ", e);
    }
}
项目:caarray    文件:FileAccessServiceStub.java   
@Override
public InputStream openInputStream(URI handle, boolean compressed) throws DataStoreException {
    checkScheme(handle);
    try {
        return new AutoCloseInputStream(FileUtils.openInputStream(openFile(handle, compressed)));
    } catch (final IOException e) {
        throw new DataStoreException("Could not open input stream for data " + handle + ":", e);
    }
}
项目:logspace    文件:SolrNativeQueryService.java   
public SolrNativeQueryResult(InputStream inputStream) {
    super();
    this.inputStream = new AutoCloseInputStream(inputStream);
}
项目:SensorPlanningService    文件:AdminControl.java   
private XmlObject parseIncomingXmlObject(InputStream payload) throws XmlException, IOException {
    // fixes https://issues.apache.org/jira/browse/XMLBEANS-226
    // @see http://commons.apache.org/io/api-release/org/apache/commons/io/input/AutoCloseInputStream.html
    XmlObject request = XmlObject.Factory.parse(new AutoCloseInputStream(payload));
    return request;
}
项目:SensorPlanningService    文件:XmlController.java   
private XmlObject parseIncomingXmlObject(InputStream payload) throws XmlException, IOException {
    // @see https://issues.apache.org/jira/browse/XMLBEANS-226
    // @see http://commons.apache.org/io/api-release/org/apache/commons/io/input/AutoCloseInputStream.html
    return XmlObject.Factory.parse(new AutoCloseInputStream(payload));
}
项目:PiratePlayar    文件:BDecoder.java   
/**
 * Decode a B-encoded byte buffer.
 *
 * <p>
 * Automatically instantiates a new BDecoder for the provided buffer and
 * decodes its root member.
 * </p>
 *
 * @param data The {@link ByteBuffer} to read from.
 */
public static BEValue bdecode(ByteBuffer data) throws IOException {
    return BDecoder.bdecode(new AutoCloseInputStream(
        new ByteArrayInputStream(data.array())));
}
项目:TorrentWeb    文件:BDecoder.java   
/**
 * Decode a B-encoded byte buffer.
 *
 * <p>
 * Automatically instantiates a new BDecoder for the provided buffer and
 * decodes its root member.
 * </p>
 *
 * @param data The {@link ByteBuffer} to read from.
 */
public static BEValue bdecode(ByteBuffer data) throws IOException {
    return BDecoder.bdecode(new AutoCloseInputStream(
            new ByteArrayInputStream(data.array())));
}
项目:Flashtool    文件:BDecoder.java   
/**
 * Decode a B-encoded byte buffer.
 *
 * <p>
 * Automatically instantiates a new BDecoder for the provided buffer and
 * decodes its root member.
 * </p>
 *
 * @param data The {@link ByteBuffer} to read from.
 */
public static BEValue bdecode(ByteBuffer data) throws IOException {
    return BDecoder.bdecode(new AutoCloseInputStream(
        new ByteArrayInputStream(data.array())));
}
项目:bitworker    文件:BDecoder.java   
/**
 * Decode a B-encoded byte buffer.
 *
 * <p>
 * Automatically instantiates a new BDecoder for the provided buffer and
 * decodes its root member.
 * </p>
 *
 * @param data The {@link ByteBuffer} to read from.
 */
public static BEValue bdecode(ByteBuffer data) throws IOException {
    return BDecoder.bdecode(new AutoCloseInputStream(
        new ByteArrayInputStream(data.array())));
}