@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
@Override public int available() throws IOException { return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
private static byte[] inflate(byte[] input) throws IOException { InflaterInputStream gzis = new InflaterInputStream(new ByteArrayInputStream(input)); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; while(gzis.available() > 0) { int l = gzis.read(buffer); if(l > 0) out.write(buffer, 0, l); } return out.toByteArray(); }
/** * Provide a more InputStream compatible version. A return value of 1 means that it is likely to read one * byte without blocking, 0 means that the system is known to block for more input. * * @return 0 if no data is available, 1 otherwise * @throws IOException */ @Override public int available() throws IOException { /* * aSmack related remark (where KXmlParser is used): * This is one of the funny code blocks. InflaterInputStream.available violates the contract of * InputStream.available, which breaks kXML2. * * I'm not sure who's to blame, oracle/sun for a broken api or the google guys for mixing a sun bug with * a xml reader that can't handle it.... * * Anyway, this simple if breaks suns distorted reality, but helps to use the api as intended. */ if (inf.needsInput()) { return 0; } return super.available(); } };
@Override public int available() throws IOException { if (this.available < 0) { return super.available(); } return this.available; }
@Override public int available() throws IOException { if (this.available < 0) { return super.available(); } return this.available; }
@Override public int available() throws IOException { if (this.available < 0) { return super.available(); } return this.available; }
@Override public int available() throws IOException { if (this.available < 0) { return super.available(); } return this.available; } @Override
@Override public int available() throws IOException { if (this.available < 0) { return super.available(); } return this.available; }
@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
@Override public int available() throws IOException { if (closed) { // Our superclass will throw an exception, but there's a jtreg test that // explicitly checks that the InputStream returned from ZipFile.getInputStream // returns 0 even when closed. return 0; } return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
GZIPInputStream zis = new GZIPInputStream(new FileInputStream(new File("myFile.gz"))); long size = 0; while (zis.available() > 0) { byte[] buf = new byte[1024]; int read = zis.read(buf); if (read > 0) size += read; } System.out.println("File Size: " + size + "bytes"); zis.close();
@Override public int available() throws IOException { return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead); } }
private static byte[] inflate(byte[] input) throws IOException { InflaterInputStream gzis = new InflaterInputStream(new ByteArrayInputStream(input)); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; while(gzis.available() > 0) { int l = gzis.read(buffer); if(l > 0) out.write(buffer, 0, l); } return out.toByteArray(); }
private static byte[] inflate(byte[] input) throws IOException { InflaterInputStream gzis = new InflaterInputStream(new ByteArrayInputStream(input)); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; while(gzis.available() > 0) { int l = gzis.read(buffer); if(l > 0) out.write(buffer, 0, l); } return out.toByteArray(); }
byte[] content = getContent(packet.getData()); if (content.length > 0) { InputStream byteIS = new ByteArrayInputStream(content); SessionInputBufferImpl contentBuf = new SessionInputBufferImpl(new HttpTransportMetricsImpl(), content.length); contentBuf.bind(byteIS); ChunkedInputStream chunkedIS = new ChunkedInputStream(contentBuf); GZIPInputStream gzipIS = new GZIPInputStream(chunkedIS); while (gzipIS.available() != 0) { byte[] buf = new byte[128]; gzipIS.read(buf); contentBuilder.append(new String(buf, "UTF-8")); } gzipIS.close(); String contentString = contentBuilder.toString(); }