当前位置: 首页>>代码示例>>Java>>正文


Java CloseShieldInputStream类代码示例

本文整理汇总了Java中org.apache.commons.io.input.CloseShieldInputStream的典型用法代码示例。如果您正苦于以下问题:Java CloseShieldInputStream类的具体用法?Java CloseShieldInputStream怎么用?Java CloseShieldInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CloseShieldInputStream类属于org.apache.commons.io.input包,在下文中一共展示了CloseShieldInputStream类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: walkRecursive

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:centic9,项目名称:IntelliJ-Action-IDs,代码行数:27,代码来源:ZipFileWalker.java

示例2: FixedLengthInputStream

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
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;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:8,代码来源:FixedLengthInputStream.java

示例3: run

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
@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;
}
 
开发者ID:ICIJ,项目名称:extract,代码行数:14,代码来源:LoadReportTask.java

示例4: run

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
@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;
}
 
开发者ID:ICIJ,项目名称:extract,代码行数:14,代码来源:LoadQueueTask.java

示例5: processMetaData

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
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 );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:28,代码来源:P2Unzipper.java

示例6: walkRecursive

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
@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;
}
 
开发者ID:centic9,项目名称:commons-dost,代码行数:31,代码来源:ZipFileWalker.java

示例7: parse

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
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);
	}
}
 
开发者ID:eluinstra,项目名称:bag-etl,代码行数:13,代码来源:SimpleMutatiesParser.java

示例8: parse

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
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);
	}
}
 
开发者ID:eluinstra,项目名称:bag-etl,代码行数:13,代码来源:BatchExtractParser.java

示例9: generateConfigFromUserPrompt

import org.apache.commons.io.input.CloseShieldInputStream; //导入依赖的package包/类
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;
}
 
开发者ID:jdupl,项目名称:lancoder,代码行数:38,代码来源:ConfigFactory.java


注:本文中的org.apache.commons.io.input.CloseShieldInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。