本文整理了Java中java.util.zip.GZIPInputStream.close()
方法的一些代码示例,展示了GZIPInputStream.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GZIPInputStream.close()
方法的具体详情如下:
包路径:java.util.zip.GZIPInputStream
类名称:GZIPInputStream
方法名:close
[英]Closes this stream and any underlying streams.
[中]关闭此流和任何基础流。
代码示例来源:origin: apache/storm
public static byte[] gunzip(byte[] data) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ByteArrayInputStream bis = new ByteArrayInputStream(data);
GZIPInputStream in = new GZIPInputStream(bis);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = in.read(buffer)) >= 0) {
bos.write(buffer, 0, len);
}
in.close();
bos.close();
return bos.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: facebook/stetho
@Override
public Void call() throws IOException {
GZIPInputStream in = new GZIPInputStream(mIn);
try {
Util.copy(in, mOut, new byte[1024]);
} finally {
in.close();
mOut.close();
}
return null;
}
}
代码示例来源:origin: aragozin/jvm-tools
private static boolean isGZIP(File headDump) {
try {
FileInputStream in = new FileInputStream(headDump);
GZIPInputStream is;
try {
is = new GZIPInputStream(in);
is.read();
is.close();
return true;
} catch (IOException e) {
in.close();
}
} catch (IOException e) {
// ignore
}
return false;
}
代码示例来源:origin: scouter-project/scouter
public static byte[] unZip(byte[] data) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(data);
java.util.zip.GZIPInputStream gin = new GZIPInputStream(in);
data = FileUtil.readAll(gin);
gin.close();
return data;
}
}
代码示例来源:origin: apache/cloudstack
public static ByteBuffer doDecompress(ByteBuffer buffer, int length) {
byte[] byteArrayIn = new byte[1024];
ByteArrayInputStream byteIn;
if (buffer.hasArray()) {
byteIn = new ByteArrayInputStream(buffer.array(), buffer.position() + buffer.arrayOffset(), buffer.remaining());
} else {
byte[] array = new byte[buffer.limit() - buffer.position()];
buffer.get(array);
byteIn = new ByteArrayInputStream(array);
}
ByteBuffer retBuff = ByteBuffer.allocate(length);
int len = 0;
try {
GZIPInputStream in = new GZIPInputStream(byteIn);
while ((len = in.read(byteArrayIn)) > 0) {
retBuff.put(byteArrayIn, 0, len);
}
in.close();
} catch (IOException e) {
s_logger.error("Fail to decompress the request!", e);
}
retBuff.flip();
return retBuff;
}
代码示例来源:origin: weibocom/motan
public static byte[] unGzip(byte[] data) throws IOException {
GZIPInputStream gzip = null;
try {
gzip = new GZIPInputStream(new ByteArrayInputStream(data));
byte[] buf = new byte[2048];
int size = -1;
ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length + 1024);
while ((size = gzip.read(buf, 0, buf.length)) != -1) {
bos.write(buf, 0, size);
}
return bos.toByteArray();
} finally {
if (gzip != null) {
gzip.close();
}
}
}
}
代码示例来源:origin: scouter-project/scouter
public static byte[] unZip(byte[] data) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(data);
java.util.zip.GZIPInputStream gin = new GZIPInputStream(in);
data = FileUtil.readAll(gin);
gin.close();
return data;
}
}
代码示例来源:origin: loklak/loklak_server
public static void gunzip(File source, File dest, boolean deleteSource) throws IOException {
byte[] buffer = new byte[2^20];
FileOutputStream out = new FileOutputStream(dest);
GZIPInputStream in = new GZIPInputStream(new BufferedInputStream(new FileInputStream(source)));
int l; while ((l = in.read(buffer)) > 0) out.write(buffer, 0, l);
in.close(); out.close();
if (deleteSource && dest.exists()) source.delete();
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
ObjectMetadata objMet = obj.getObjectMetadata();
FileOutputStream fos = new FileOutputStream(cachedFile);
GZIPInputStream gis = new GZIPInputStream(obj.getObjectContent());
try {
ByteStreams.copy(gis, fos);
} finally {
fos.close();
gis.close();
代码示例来源:origin: apache/storm
public static byte[] readCompressedByteArray(DataInput in) throws IOException {
int length = in.readInt();
if (length == -1) {
return null;
}
byte[] buffer = new byte[length];
in.readFully(buffer); // could/should use readFully(buffer,0,length)?
GZIPInputStream gzi = new GZIPInputStream(new ByteArrayInputStream(buffer, 0, buffer.length));
byte[] outbuf = new byte[length];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int len;
while ((len = gzi.read(outbuf, 0, outbuf.length)) != -1) {
bos.write(outbuf, 0, len);
}
byte[] decompressed = bos.toByteArray();
bos.close();
gzi.close();
return decompressed;
}
代码示例来源:origin: scouter-project/scouter
public static byte[] unZip(byte[] data) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(data);
java.util.zip.GZIPInputStream gin = new GZIPInputStream(in);
data = FileUtil.readAll(gin);
gin.close();
return data;
}
}
代码示例来源:origin: deeplearning4j/dl4j-examples
private static void extractGzip(String filePath, String outputPath) throws IOException {
System.out.println("Extracting files...");
byte[] buffer = new byte[BUFFER_SIZE];
try{
GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(new File(filePath)));
FileOutputStream out = new FileOutputStream(new File(outputPath));
int len;
while ((len = gzis.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
gzis.close();
out.close();
System.out.println("Done");
}catch(IOException ex){
ex.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
final GZIPInputStream in = new GZIPInputStream(new FileInputStream(inputFile));
final FileOutputStream out = new FileOutputStream(outputFile);
in.close();
out.close();
代码示例来源:origin: alibaba/jstorm
public static byte[] gunzip(byte[] data) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ByteArrayInputStream bis = new ByteArrayInputStream(data);
GZIPInputStream in = new GZIPInputStream(bis);
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) >= 0) {
bos.write(buffer, 0, len);
}
in.close();
bos.close();
return bos.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: scouter-project/scouter
public static byte[] unZip(byte[] data) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(data);
java.util.zip.GZIPInputStream gin = new GZIPInputStream(in);
data = FileUtil.readAll(gin);
gin.close();
return data;
}
}
代码示例来源:origin: wangdan/AisenWeiBo
public static File decodeGZipFile(File file) throws Throwable {
GZIPInputStream gzipIn = null;
FileOutputStream gzipOut = null;
try {
gzipIn = new GZIPInputStream(new FileInputStream(file));
file = new File(file.getAbsolutePath() + ".gziptemp");
gzipOut = new FileOutputStream(file);
byte[] buf = new byte[1024 * 8];
int num = -1;
while ((num = gzipIn.read(buf, 0, buf.length)) != -1) {
gzipOut.write(buf, 0, num);
}
} finally {
if (gzipIn != null)
gzipIn.close();
if (gzipOut != null)
gzipOut.close();
}
return file;
}
代码示例来源:origin: pentaho/pentaho-kettle
data.fis.add( fi );
if ( data.compressFiles ) {
di = getDataInputStream( new GZIPInputStream( new BufferedInputStream( fi ) ) );
} else {
di = new DataInputStream( new BufferedInputStream( fi, 50000 ) );
fi.close();
if ( gzfi != null ) {
gzfi.close();
代码示例来源:origin: loklak/loklak_server
public static byte[] gunzip(byte[] b) {
byte[] buffer = new byte[Math.min(2^20, b.length)];
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(b.length * 2);
GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(b), Math.min(65536, b.length));
int l; while ((l = in.read(buffer)) > 0) baos.write(buffer, 0, l);
in.close();
baos.close();
return baos.toByteArray();
} catch (IOException e) {}
return null;
}
代码示例来源:origin: scouter-project/scouter
public static byte[] unZip(byte[] data) throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(data);
java.util.zip.GZIPInputStream gin = new GZIPInputStream(in);
data = FileUtil.readAll(gin);
gin.close();
return data;
}
}
代码示例来源:origin: cymcsg/UltimateAndroid
in = new GZIPInputStream(new FileInputStream(inFileName));
} catch (FileNotFoundException e) {
System.err.println("File not found. " + inFileName);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
} finally {
try {
if (in != null) in.close();
if (out != null) out.close();
} catch (IOException e) {
内容来源于网络,如有侵权,请联系作者删除!