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

项目:IntelliJ-Action-IDs    文件:ZipFileWalker.java   
@SuppressWarnings("resource")
private void walkRecursive(File base, InputStream stream, Multimap<String, ActionIDDef> idsPerFile) throws IOException {
    ZipInputStream zipStream = new ZipInputStream(stream);
    while(true) {
        final ZipEntry entry;
        try {
            entry = zipStream.getNextEntry();
        } catch (IOException e) {
            throw new IOException("While handling file: " + base, e);
        }

        if(entry == null) {
            break;
        }

        File file = new File(base, entry.getName());
        if(ActionIDDef.isActionFile(file)) {
            idsPerFile.putAll(file.getPath(), ActionIDDef.parse(new CloseShieldInputStream(zipStream), new File(entry.getName()).getName()));
        }

        if(ZipUtils.isZip(entry.getName())) {
            walkRecursive(file, zipStream, idsPerFile);
        }
        zipStream.closeEntry();
    }
}
项目:aliyun-maxcompute-data-collectors    文件:FixedLengthInputStream.java   
public FixedLengthInputStream(InputStream stream, long maxLen) {
  super(new CountingInputStream(new CloseShieldInputStream(stream)));

  // Save a correctly-typed reference to the underlying stream.
  this.countingIn = (CountingInputStream) this.in;
  this.maxBytes = maxLen;
}
项目:extract    文件:LoadReportTask.java   
@Override
public Void run() throws Exception {
    final DocumentFactory factory = new DocumentFactory().configure(options);

    try (final InputStream input = new CloseShieldInputStream(System.in);
         final ReportMap reportMap = new ReportMapFactory(options)
                 .withDocumentFactory(factory)
                 .createShared()) {
        load(factory, reportMap, input);
    }

    return null;
}
项目:extract    文件:LoadQueueTask.java   
@Override
public Void run() throws Exception {
    final DocumentFactory factory = new DocumentFactory().configure(options);

    try (final InputStream input = new CloseShieldInputStream(System.in);
         final DocumentQueue queue = new DocumentQueueFactory(options)
                 .withDocumentFactory(factory)
                 .createShared()) {
        load(factory, queue, input);
    }

    return null;
}
项目:packagedrone    文件:P2Unzipper.java   
private void processMetaData ( final Context context, final InputStream in, final String filename, final String xpath ) throws Exception
{
    // parse input
    final Document doc = this.xml.newDocumentBuilder ().parse ( new CloseShieldInputStream ( in ) );
    final XPathExpression path = this.xml.newXPathFactory ().newXPath ().compile ( xpath );

    // filter
    final NodeList result = XmlHelper.executePath ( doc, path );

    // write filtered output
    final Document fragmentDoc = this.xml.newDocumentBuilder ().newDocument ();
    Node node = result.item ( 0 );
    node = fragmentDoc.adoptNode ( node );
    fragmentDoc.appendChild ( node );

    // create artifact
    context.createVirtualArtifact ( filename, out -> {
        try
        {
            XmlHelper.write ( this.xml.newTransformerFactory (), fragmentDoc, new StreamResult ( out ) );
        }
        catch ( final Exception e )
        {
            throw new IOException ( e );
        }
    }, null );
}
项目:commons-dost    文件:ZipFileWalker.java   
@SuppressWarnings("resource")
private boolean walkRecursive(File base, InputStream stream, OutputHandler handler) throws IOException {
    ZipInputStream zipStream = new ZipInputStream(stream);
    while(true) {
        final ZipEntry entry;
        try {
            entry = zipStream.getNextEntry();
        } catch (IOException e) {
            throw new IOException("While handling file: " + base, e);
        }

        if(entry == null) {
            break;
        }

        File file = new File(base, entry.getName());
        if(handler.found(file, new CloseShieldInputStream(zipStream))) {
            return true;
        }

        if(ZipUtils.isZip(entry.getName())) {
            if(walkRecursive(file, zipStream, handler)) {
                return true;
            }
        }
        zipStream.closeEntry();
    }

    return false;
}
项目:zSqoop    文件:FixedLengthInputStream.java   
public FixedLengthInputStream(InputStream stream, long maxLen) {
  super(new CountingInputStream(new CloseShieldInputStream(stream)));

  // Save a correctly-typed reference to the underlying stream.
  this.countingIn = (CountingInputStream) this.in;
  this.maxBytes = maxLen;
}
项目:bag-etl    文件:SimpleMutatiesParser.java   
public void parse(InputStream is) throws ParseException, HandlerException
{
    try
    {
        BAGMutatiesDeelbestandLVC mutaties = objectBuilder.handle(new CloseShieldInputStream(is));
        parse(mutaties);
    }
    catch (XMLStreamException | FactoryConfigurationError | JAXBException e)
    {
        throw new ParseException(e);
    }
}
项目:bag-etl    文件:BatchExtractParser.java   
public void parse(InputStream is) throws ParseException, HandlerException
{
    try
    {
        BAGExtractDeelbestandLVC extract = objectBuilder.handle(new CloseShieldInputStream(is));
        parse(extract);
    }
    catch (XMLStreamException | FactoryConfigurationError | JAXBException e)
    {
        throw new ParseException(e);
    }
}
项目:bag-etl    文件:SimpleExtractParser.java   
public void parse(InputStream is) throws ParseException, HandlerException
{
    try
    {
        BAGExtractDeelbestandLVC extract = objectBuilder.handle(new CloseShieldInputStream(is));
        parse(extract);
    }
    catch (XMLStreamException | FactoryConfigurationError | JAXBException e)
    {
        throw new ParseException(e);
    }
}
项目:lancoder    文件:ConfigFactory.java   
private T generateConfigFromUserPrompt() {
    System.out.println("Please enter the following fields. Default values are in [].");
    System.out.println("To use the default value, hit return.");
    T config = null;

    try (Scanner s = new Scanner(new CloseShieldInputStream(System.in))) {
        // Finish setting up the scanner
        s.useDelimiter(System.lineSeparator());

        // Determine if the user wants to change advanced configuration
        boolean useAdvancedSettings = promptUserForAdvancedSettings(s);

        // Load fields dynamically from the provided configuration class
        config = clazz.newInstance();
        ArrayList<Entry<Field, Prompt>> fields = getFields(useAdvancedSettings);

        for (Entry<Field, Prompt> entry : fields) {
            Field field = entry.getKey();
            String message = entry.getValue().message();
            field.setAccessible(true);

            System.out.printf("%s [%s]: ", message, field.get(config));
            String input = s.nextLine();

            if (!input.isEmpty()) {
                if (field.getType() == java.lang.Integer.TYPE) {
                    field.set(config, Integer.valueOf(input));
                } else {
                    field.set(config, input);
                }
            }
        }
    } catch (InstantiationException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return config;
}
项目:sqoop    文件:FixedLengthInputStream.java   
public FixedLengthInputStream(InputStream stream, long maxLen) {
  super(new CountingInputStream(new CloseShieldInputStream(stream)));

  // Save a correctly-typed reference to the underlying stream.
  this.countingIn = (CountingInputStream) this.in;
  this.maxBytes = maxLen;
}