本文整理匯總了Java中java.util.zip.InflaterInputStream.close方法的典型用法代碼示例。如果您正苦於以下問題:Java InflaterInputStream.close方法的具體用法?Java InflaterInputStream.close怎麽用?Java InflaterInputStream.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.zip.InflaterInputStream
的用法示例。
在下文中一共展示了InflaterInputStream.close方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: inflate
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static byte[] inflate(InputStream stream) throws IOException {
InflaterInputStream inputStream = new InflaterInputStream(stream);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
try {
while ((length = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, length);
}
} finally {
buffer = outputStream.toByteArray();
outputStream.flush();
outputStream.close();
inputStream.close();
}
return buffer;
}
示例2: FlateDecode
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
/** A helper to FlateDecode.
* @param in the input data
* @param strict <CODE>true</CODE> to read a correct stream. <CODE>false</CODE>
* to try to read a corrupted stream
* @return the decoded data
*/
public static byte[] FlateDecode(byte in[], boolean strict) {
ByteArrayInputStream stream = new ByteArrayInputStream(in);
InflaterInputStream zip = new InflaterInputStream(stream);
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte b[] = new byte[strict ? 4092 : 1];
try {
int n;
while ((n = zip.read(b)) >= 0) {
out.write(b, 0, n);
}
zip.close();
out.close();
return out.toByteArray();
}
catch (Exception e) {
if (strict)
return null;
return out.toByteArray();
}
}
示例3: readScriptFile
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static String readScriptFile(String path) {
String str = "";
try {
InflaterInputStream infis = new InflaterInputStream(new FileInputStream(path));
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
int buffer;
while ((buffer = infis.read()) != -1) {
baos.write(buffer);
}
infis.close();
baos.close();
str = new String(baos.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
示例4: inflate
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static byte[] inflate(InputStream stream) throws IOException {
InflaterInputStream inputStream = new InflaterInputStream(stream);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, length);
}
buffer = outputStream.toByteArray();
outputStream.flush();
outputStream.close();
inputStream.close();
return buffer;
}
示例5: read
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
private byte[] read(byte[] data, int pos) throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream bis = new ByteArrayInputStream(data);
Header header = new Header();
header.read(data, pos);
bis.skip(pos + header.getSize());
InflaterInputStream inflater = new InflaterInputStream(bis);
byte[] chunk = new byte[4096];
int count;
while ((count = inflater.read(chunk)) >= 0)
{
out.write(chunk, 0, count);
}
inflater.close();
return out.toByteArray();
}
示例6: internalReadStream
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
private BufferExposingByteArrayOutputStream internalReadStream(int record) throws IOException {
waitForPendingWriteForRecord(record);
byte[] result;
synchronized (myLock) {
result = super.readBytes(record);
}
InflaterInputStream in = new CustomInflaterInputStream(result);
try {
final BufferExposingByteArrayOutputStream outputStream = new BufferExposingByteArrayOutputStream();
StreamUtil.copyStreamContent(in, outputStream);
return outputStream;
}
finally {
in.close();
}
}
示例7: inflate
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
private static byte[] inflate(InputStream stream) throws IOException {
InflaterInputStream inputStream = new InflaterInputStream(stream);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int length;
try {
while ((length = inputStream.read(buf.get())) != -1) {
outputStream.write(buf.get(), 0, length);
}
} finally {
buf.set(outputStream.toByteArray());
outputStream.flush();
outputStream.close();
inputStream.close();
}
return buf.get();
}
示例8: b
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public static byte[] b(byte[] bArr) {
int i = 0;
if (bArr == null) {
return null;
}
InputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
InflaterInputStream inflaterInputStream = new InflaterInputStream(byteArrayInputStream);
Object obj = new byte[0];
Object obj2 = new byte[1024];
while (true) {
try {
Object obj3;
int read = inflaterInputStream.read(obj2);
if (read > 0) {
i += read;
obj3 = new byte[i];
System.arraycopy(obj, 0, obj3, 0, obj.length);
System.arraycopy(obj2, 0, obj3, obj.length, read);
} else {
obj3 = obj;
}
if (read <= 0) {
try {
byteArrayInputStream.close();
inflaterInputStream.close();
return obj3;
} catch (IOException e) {
return null;
}
}
obj = obj3;
} catch (Exception e2) {
return null;
}
}
}
示例9: inflateInputStreamTest
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
@Test
public void inflateInputStreamTest() throws IOException {
File f = new File("/tmp/doc.2");
InflaterInputStream iis = new InflaterInputStream(new FileInputStream(f), new Inflater());
int i = 0, count = 0;
while((i = iis.read()) != -1) {
count++;
System.out.println(i);
}
iis.close();
}
示例10: getData
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
/**
* Extract compressed WMF data from a ppt
*/
public byte[] getData()
{
try
{
byte[] rawdata = getRawData();
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream is = new ByteArrayInputStream(rawdata);
is.skip(8);
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE);
is.skip(header.getSize() + CHECKSUM_SIZE);
// AldusHeader aldus = new AldusHeader();
// aldus.left = header.bounds.x;
// aldus.top = header.bounds.y;
// aldus.right = header.bounds.x + header.bounds.width;
// aldus.bottom = header.bounds.y + header.bounds.height;
// aldus.write(out);
InflaterInputStream inflater = new InflaterInputStream(is);
byte[] chunk = new byte[4096];
int count;
while ((count = inflater.read(chunk)) >= 0)
{
out.write(chunk, 0, count);
}
inflater.close();
return out.toByteArray();
}
catch(IOException e)
{
throw new HSLFException(e);
}
}
示例11: getData
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
/**
* Extract compressed EMF data from a ppt
*/
public byte[] getData()
{
try
{
byte[] rawdata = getRawData();
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream is = new ByteArrayInputStream(rawdata);
is.skip(8);
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE);
is.skip(header.getSize() + CHECKSUM_SIZE);
InflaterInputStream inflater = new InflaterInputStream(is);
byte[] chunk = new byte[4096];
int count;
while ((count = inflater.read(chunk)) >= 0)
{
out.write(chunk, 0, count);
}
inflater.close();
return out.toByteArray();
}
catch(IOException e)
{
throw new HSLFException(e);
}
}
示例12: writeByte_WMFAndEMF
import java.util.zip.InflaterInputStream; //導入方法依賴的package包/類
public void writeByte_WMFAndEMF(FileOutputStream out)
{
try
{
byte[] rawdata = getRawData();
InputStream is = new ByteArrayInputStream(rawdata);
is.skip(8);
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE);
is.skip(header.getSize() + CHECKSUM_SIZE);
InflaterInputStream inflater = new InflaterInputStream(is);
byte[] chunk = new byte[4096];
int count;
while ((count = inflater.read(chunk)) >= 0)
{
out.write(chunk, 0, count);
}
inflater.close();
}
catch(IOException e)
{
throw new HSLFException(e);
}
}