本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}