本文整理了Java中java.util.zip.GZIPInputStream.available()
方法的一些代码示例,展示了GZIPInputStream.available()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GZIPInputStream.available()
方法的具体详情如下:
包路径:java.util.zip.GZIPInputStream
类名称:GZIPInputStream
方法名:available
暂无
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@SuppressWarnings("unchecked")
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
try
{
GZIPCompressedMessage result = new GZIPCompressedMessage();
byte[] byteArray = new byte[data.remaining()];
data.get(byteArray);
GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(byteArray));
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] tmp = new byte[9012];
int read;
while (in.available() > 0 && ((read = in.read(tmp)) > 0)) {
out.write(tmp, 0, read);
}
result.setMessage((Message)Serializer.readClassAndObject(ByteBuffer.wrap(out.toByteArray())));
return (T)result;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e.toString());
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while( gzReader.available() != 0 )
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while( gzReader.available() != 0 )
代码示例来源:origin: org.codehaus.izpack/izpack-core
/**
* (non-Javadoc)
*
* @see java.io.InputStream#available()
*/
@Override
public int available() throws IOException
{
return zippedInputStream.available();
}
代码示例来源:origin: org.netbeans.api/org-jruby
private boolean isEof() throws IOException {
return ((GZIPInputStream)io).available() != 1;
}
代码示例来源:origin: Gerrygames/ViaRewind
public static byte[] decompress(byte[] contentBytes){
ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(contentBytes));
while (stream.available()>0) {
out.write(stream.read());
}
} catch(IOException e){
throw new RuntimeException(e);
}
return out.toByteArray();
}
}
代码示例来源:origin: senseidb/zoie
public static byte[] uncompress(byte[] src) throws IOException {
byte[] buffer = new byte[1024]; // 1k buffer
ByteArrayInputStream bin = new ByteArrayInputStream(src);
GZIPInputStream gzipIn = new GZIPInputStream(bin);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
while (gzipIn.available() > 0) {
int len = gzipIn.read(buffer);
if (len <= 0) break;
if (len < buffer.length) {
bout.write(buffer, 0, len);
} else {
bout.write(buffer);
}
}
bout.flush();
return bout.toByteArray();
}
代码示例来源:origin: com.linkedin.zoie/zoie-core
public static byte[] uncompress(byte[] src) throws IOException{
byte[] buffer = new byte[1024]; // 1k buffer
ByteArrayInputStream bin = new ByteArrayInputStream(src);
GZIPInputStream gzipIn = new GZIPInputStream(bin);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
while(gzipIn.available()>0){
int len = gzipIn.read(buffer);
if (len<=0) break;
if (len<buffer.length){
bout.write(buffer, 0, len);
}
else{
bout.write(buffer);
}
}
bout.flush();
return bout.toByteArray();
}
代码示例来源:origin: com.senseidb.zoie/zoie-core
public static byte[] uncompress(byte[] src) throws IOException {
byte[] buffer = new byte[1024]; // 1k buffer
ByteArrayInputStream bin = new ByteArrayInputStream(src);
GZIPInputStream gzipIn = new GZIPInputStream(bin);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
while (gzipIn.available() > 0) {
int len = gzipIn.read(buffer);
if (len <= 0) break;
if (len < buffer.length) {
bout.write(buffer, 0, len);
} else {
bout.write(buffer);
}
}
bout.flush();
return bout.toByteArray();
}
代码示例来源:origin: org.rcsb/mmtf-codec
/**
* Deflate a gzip byte array.
*
* @param inputBytes a gzip compressed byte array
* @return a deflated byte array
* @throws IOException error in gzip input stream
*/
public static byte[] deflateGzip(byte[] inputBytes) throws IOException {
ByteArrayOutputStream byteArrayOutputStream
= new ByteArrayOutputStream();
try (GZIPInputStream gzipInputStream = new GZIPInputStream(
new ByteArrayInputStream(inputBytes))) {
byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
while (gzipInputStream.available() == 1) {
int size = gzipInputStream.read(buffer);
if (size == -1) {
break;
}
byteArrayOutputStream.write(buffer, 0, size);
}
return byteArrayOutputStream.toByteArray();
}
}
代码示例来源:origin: org.rcsb/mmtf-decoder
/**
* Deflate a gzip byte array.
* @param inputBytes a gzip compressed byte array
* @return a deflated byte array
* @throws IOException error in gzip input stream
*/
public static byte[] deflateGzip(byte[] inputBytes) throws IOException {
// Start the byte input stream
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(inputBytes);
GZIPInputStream gzipInputStream;
ByteArrayOutputStream byteArrayOutputStream = null;
try {
gzipInputStream = new GZIPInputStream(byteInputStream);
byteArrayOutputStream = new ByteArrayOutputStream();
// Make a buffer
byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
while (gzipInputStream.available() == 1) {
int size = gzipInputStream.read(buffer);
if(size==-1){
break;
}
byteArrayOutputStream.write(buffer, 0, size);
}
} finally {
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
}
return byteArrayOutputStream.toByteArray();
}
代码示例来源:origin: p455w0rd/WirelessCraftingTerminal
public PacketMEInventoryUpdate(final ByteBuf stream) throws IOException {
data = null;
compressFrame = null;
list = new LinkedList<IAEItemStack>();
ref = stream.readByte();
final GZIPInputStream gzReader = new GZIPInputStream(new InputStream() {
@Override
public int read() throws IOException {
if (stream.readableBytes() <= 0) {
return -1;
}
return stream.readByte() & STREAM_MASK;
}
});
final ByteBuf uncompressed = Unpooled.buffer(stream.readableBytes());
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while (gzReader.available() != 0) {
final int bytes = gzReader.read(tmp);
if (bytes > 0) {
uncompressed.writeBytes(tmp, 0, bytes);
}
}
gzReader.close();
while (uncompressed.readableBytes() > 0) {
list.add(AEItemStack.fromPacket(uncompressed));
}
empty = list.isEmpty();
}
代码示例来源:origin: org.jmonkeyengine/jme3-networking
@SuppressWarnings("unchecked")
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
try
{
GZIPCompressedMessage result = new GZIPCompressedMessage();
byte[] byteArray = new byte[data.remaining()];
data.get(byteArray);
GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(byteArray));
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] tmp = new byte[9012];
int read;
while (in.available() > 0 && ((read = in.read(tmp)) > 0)) {
out.write(tmp, 0, read);
}
result.setMessage((Message)Serializer.readClassAndObject(ByteBuffer.wrap(out.toByteArray())));
return (T)result;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e.toString());
}
}
代码示例来源:origin: info.projectkyoto/mms-engine
@SuppressWarnings("unchecked")
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
try
{
GZIPCompressedMessage result = new GZIPCompressedMessage();
byte[] byteArray = new byte[data.remaining()];
data.get(byteArray);
GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(byteArray));
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] tmp = new byte[9012];
int read;
while (in.available() > 0 && ((read = in.read(tmp)) > 0)) {
out.write(tmp, 0, read);
}
result.setMessage((Message)Serializer.readClassAndObject(ByteBuffer.wrap(out.toByteArray())));
return (T)result;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e.toString());
}
}
代码示例来源:origin: PerfCake/PerfCake
/**
* Replays the recorded data through the scenario's reporters. Any instance of {@link RawReporter} is ignored.
*
* @throws IOException
* When there was an error reading the replay data.
*/
public void replay() throws IOException {
try (
final ObjectInputStream ois = new ObjectInputStream(gzip);
) {
final RunInfo originalRunInfo = (RunInfo) ois.readObject();
runInfo = new ReplayRunInfo(originalRunInfo);
reportManager.setRunInfo(runInfo);
try {
while (gzip.available() > 0) {
report(MeasurementUnit.streamIn(ois));
}
} catch (EOFException eof) {
// nothing wrong, we just stop reporting here, gzip actually keeps some excessive buffer at the end
}
resetLastTimes();
publishResults(lastTime);
} catch (ClassNotFoundException cnfe) {
throw new IOException("Unknown class in the recorded data. Make sure all the plugins are loaded that were used during recording: ", cnfe);
}
}
内容来源于网络,如有侵权,请联系作者删除!