public static void forEach(final ZipInputStream zipInputStream, final String prefix, final ResourceHandler handler) {
final int pos = prefix.length();
ZipEntry entry = null;
while ((entry = LdiZipInputStreamUtil.getNextEntry(zipInputStream)) != null) {
if (!entry.isDirectory()) {
final String entryName = entry.getName().replace('\\', '/');
if (!entryName.startsWith(prefix)) {
continue;
}
handler.processResource(entryName.substring(pos), new FilterInputStream(zipInputStream) {
public void close() throws IOException {
LdiZipInputStreamUtil.closeEntry(zipInputStream);
}
});
}
}
}
java类java.io.FilterInputStream的实例源码
ResourceTraversal.java 文件源码
项目:lasta-di
阅读 19
收藏 0
点赞 0
评论 0
JarResource.java 文件源码
项目:IoTgo_Android_App
阅读 22
收藏 0
点赞 0
评论 0
@Override
public InputStream getInputStream()
throws java.io.IOException
{
checkConnection();
if (!_urlString.endsWith("!/"))
return new FilterInputStream(super.getInputStream())
{
@Override
public void close() throws IOException {this.in=IO.getClosedStream();}
};
URL url = new URL(_urlString.substring(4,_urlString.length()-2));
InputStream is = url.openStream();
return is;
}
JarResource.java 文件源码
项目:IoTgo_Android_App
阅读 21
收藏 0
点赞 0
评论 0
@Override
public InputStream getInputStream()
throws java.io.IOException
{
checkConnection();
if (!_urlString.endsWith("!/"))
return new FilterInputStream(super.getInputStream())
{
@Override
public void close() throws IOException {this.in=IO.getClosedStream();}
};
URL url = new URL(_urlString.substring(4,_urlString.length()-2));
InputStream is = url.openStream();
return is;
}
Ec2Snitch.java 文件源码
项目:ACaZoo
阅读 24
收藏 0
点赞 0
评论 0
String awsApiCall(String url) throws IOException, ConfigurationException
{
// Populate the region and zone by introspection, fail if 404 on metadata
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
DataInputStream d = null;
try
{
conn.setRequestMethod("GET");
if (conn.getResponseCode() != 200)
throw new ConfigurationException("Ec2Snitch was unable to execute the API call. Not an ec2 node?");
// Read the information. I wish I could say (String) conn.getContent() here...
int cl = conn.getContentLength();
byte[] b = new byte[cl];
d = new DataInputStream((FilterInputStream) conn.getContent());
d.readFully(b);
return new String(b, Charsets.UTF_8);
}
finally
{
FileUtils.close(d);
conn.disconnect();
}
}
MultiInputStreamTest.java 文件源码
项目:guava-libraries
阅读 29
收藏 0
点赞 0
评论 0
public void testOnlyOneOpen() throws Exception {
final ByteSource source = newByteSource(0, 50);
final int[] counter = new int[1];
ByteSource checker = new ByteSource() {
@Override
public InputStream openStream() throws IOException {
if (counter[0]++ != 0) {
throw new IllegalStateException("More than one source open");
}
return new FilterInputStream(source.openStream()) {
@Override public void close() throws IOException {
super.close();
counter[0]--;
}
};
}
};
byte[] result = ByteSource.concat(checker, checker, checker).read();
assertEquals(150, result.length);
}
FTPBlobDownloadStrategy.java 文件源码
项目:daq-eclipse
阅读 23
收藏 0
点赞 0
评论 0
public InputStream getInputStream(ActiveMQBlobMessage message) throws IOException, JMSException {
url = message.getURL();
final FTPClient ftp = createFTP();
String path = url.getPath();
String workingDir = path.substring(0, path.lastIndexOf("/"));
String file = path.substring(path.lastIndexOf("/") + 1);
ftp.changeWorkingDirectory(workingDir);
ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
InputStream input = new FilterInputStream(ftp.retrieveFileStream(file)) {
public void close() throws IOException {
in.close();
ftp.quit();
ftp.disconnect();
}
};
return input;
}
BandStructure.java 文件源码
项目:infobip-open-jdk-8
阅读 24
收藏 0
点赞 0
评论 0
public void setInputStreamFrom(InputStream in) throws IOException {
assert(bytes == null);
assert(assertReadyToReadFrom(this, in));
setPhase(READ_PHASE);
this.in = in;
if (optDumpBands) {
// Tap the stream.
bytesForDump = new ByteArrayOutputStream();
this.in = new FilterInputStream(in) {
@Override
public int read() throws IOException {
int ch = in.read();
if (ch >= 0) bytesForDump.write(ch);
return ch;
}
@Override
public int read(byte b[], int off, int len) throws IOException {
int nr = in.read(b, off, len);
if (nr >= 0) bytesForDump.write(b, off, nr);
return nr;
}
};
}
super.readyToDisburse();
}
ClassReader.java 文件源码
项目:infobip-open-jdk-8
阅读 26
收藏 0
点赞 0
评论 0
ClassReader(Class cls, InputStream in) throws IOException {
this.pkg = cls.getPackage();
this.cls = cls;
this.verbose = pkg.verbose;
this.in = new DataInputStream(new FilterInputStream(in) {
public int read(byte b[], int off, int len) throws IOException {
int nr = super.read(b, off, len);
if (nr >= 0) inPos += nr;
return nr;
}
public int read() throws IOException {
int ch = super.read();
if (ch >= 0) inPos += 1;
return ch;
}
public long skip(long n) throws IOException {
long ns = super.skip(n);
if (ns >= 0) inPos += ns;
return ns;
}
});
}
PackageReader.java 文件源码
项目:infobip-open-jdk-8
阅读 30
收藏 0
点赞 0
评论 0
LimitedBuffer(InputStream originalIn) {
super(null, 1<<14);
servedPos = pos;
super.in = new FilterInputStream(originalIn) {
public int read() throws IOException {
if (buffered == limit)
return -1;
++buffered;
return super.read();
}
public int read(byte b[], int off, int len) throws IOException {
if (buffered == limit)
return -1;
if (limit != -1) {
long remaining = limit - buffered;
if (len > remaining)
len = (int)remaining;
}
int nr = super.read(b, off, len);
if (nr >= 0) buffered += nr;
return nr;
}
};
}
BandStructure.java 文件源码
项目:jdk8u-dev-jdk
阅读 25
收藏 0
点赞 0
评论 0
public void setInputStreamFrom(InputStream in) throws IOException {
assert(bytes == null);
assert(assertReadyToReadFrom(this, in));
setPhase(READ_PHASE);
this.in = in;
if (optDumpBands) {
// Tap the stream.
bytesForDump = new ByteArrayOutputStream();
this.in = new FilterInputStream(in) {
@Override
public int read() throws IOException {
int ch = in.read();
if (ch >= 0) bytesForDump.write(ch);
return ch;
}
@Override
public int read(byte b[], int off, int len) throws IOException {
int nr = in.read(b, off, len);
if (nr >= 0) bytesForDump.write(b, off, nr);
return nr;
}
};
}
super.readyToDisburse();
}