Package org.apache.commons.io.input

Examples of org.apache.commons.io.input.AutoCloseInputStream


    /** Wrapper around {@link #getValue()} */
    public InputStream getStream() throws RepositoryException {
        final Binary binary = getValue().getBinary();
        // make sure binary is disposed after stream had been consumed
        return new AutoCloseInputStream(binary.getStream()) {
            public void close() throws IOException {
                super.close();
                binary.dispose();
            }
        };
View Full Code Here


        public InputStream getInputStream() throws IOException
        {
           if (_file != null)
           {
               // Automatically close and delete the temp file when end of input has been reached (MULE-6732).
               return new BufferedInputStream(new AutoCloseInputStream(new DeleteOnCloseFileInputStream(_file)));
           }
           else
           {
               //part content is in a ByteArrayOutputStream
               return new ByteArrayInputStream(((ByteArrayOutputStream)_out).toByteArray());
View Full Code Here

    if (!fallbackStorageFile.exists()) {
      fallbackStorageFile.getParentFile().mkdirs();
      fallbackStorageFile.createNewFile();
      LOG.debug("created fallback storage: {}", fallbackStorageFile);
    } else {
      fallbackStorage.load(new AutoCloseInputStream(new FileInputStream(fallbackStorageFile)));
      LOG.debug("loaded fallback storage: {}", fallbackStorage);
    }
  }
View Full Code Here

      final String encoding = "UTF-8";
      IOUtils.write(content, new FileOutputStream(temp), encoding);
      LOG.debug("absolute path: {}", temp.getAbsolutePath());

      final Process process = createProcess(temp);
      final String result = IOUtils.toString(new AutoCloseInputStream(process.getInputStream()), encoding);
      final int exitStatus = process.waitFor();// this won't return till `out' stream being flushed!
      if (exitStatus != 0) {
        final String compileError = result;
        LOG.error("exitStatus: {}", exitStatus);
        // find a way to get rid of escape character found at the end (minor issue)
View Full Code Here

      /**
       * It is important to read before waitFor is invoked because read stream is blocking stdout while Java application
       * doesn't read the whole buffer. It hangs when processing large files. The lessc isn't closing till all STDOUT
       * flushed. This blocks io and Node does not exit because of that.
       */
      final String result = IOUtils.toString(new AutoCloseInputStream(process.getInputStream()), encoding);
      final int exitStatus = process.waitFor();// this won't return till `out' stream being flushed!

      if (exitStatus != 0) {
        LOG.error("exitStatus: {}", exitStatus);
        // find a way to get rid of escape character found at the end (minor issue)
View Full Code Here

    if (isResourceChanged(request)) {
      // set expiry headers
      getHeadersConfigurer().setHeaders(response);
      InputStream is = null;
      try {
        is = new AutoCloseInputStream(locatorFactory.locate(resourceUri));
        final int length = IOUtils.copy(is, outputStream);
        // servlet engine may ignore this if content body is flushed to client
        response.setContentLength(length);
        response.setStatus(HttpServletResponse.SC_OK);
      } finally {
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public InputStream locate(final String uri)
      throws IOException {
    return new AutoCloseInputStream(locatorFactory.locate(uri));
  }
View Full Code Here

    final UriLocator uriLocator = getInstance(uri);
    if (uriLocator == null) {
      throw new WroRuntimeException("No locator is capable of handling uri: " + uri);
    }
    LOG.debug("[OK] locating {} using locator: {}", uri, uriLocator.getClass().getSimpleName());
    return new AutoCloseInputStream(uriLocator.locate(uri));
  }
View Full Code Here

    final XmlModelFactory importedModelFactory = new XmlModelFactory(this.processedImports) {
      @Override
      protected InputStream getModelResourceAsStream()
          throws IOException {
        LOG.debug("build model from import: {}", modelLocation);
        return new AutoCloseInputStream(locatorFactory.locate(modelLocation));
      };
    };
    // inject manually created modelFactory
    injector.inject(importedModelFactory);
    try {
View Full Code Here

TOP

Related Classes of org.apache.commons.io.input.AutoCloseInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.