162 } catch (DataFormatException e) { 163 String s = e.getMessage(); 164 throw new ZipException(s != null ? s : "Invalid ZLIB data format"); 165 } 166 } 167 168 /** 169 * Returns 0 after EOF has been reached, otherwise always return 1. 170 * <p> 171 * Programs should not count on this method to return the actual number 172 * of bytes that could be read without blocking. 173 * 174 * @return 1 before EOF and 0 after EOF. 175 * @exception IOException if an I/O error occurs. 176 * 177 */ 178 public int available() throws IOException { 179 ensureOpen(); 180 if (reachEOF) { 181 return 0; 182 } else { 183 return 1; 184 } 185 } 186 187 private byte[] b = new byte[512]; 188 189 /** 190 * Skips specified number of bytes of uncompressed data. 191 * @param n the number of bytes to skip 192 * @return the actual number of bytes skipped. 193 * @exception IOException if an I/O error has occurred 194 * @exception IllegalArgumentException if {@code n < 0} 195 */ 196 public long skip(long n) throws IOException { 197 if (n < 0) { 198 throw new IllegalArgumentException("negative skip length"); 199 } 200 ensureOpen(); 201 int max = (int)Math.min(n, Integer.MAX_VALUE); | 162 } catch (DataFormatException e) { 163 String s = e.getMessage(); 164 throw new ZipException(s != null ? s : "Invalid ZLIB data format"); 165 } 166 } 167 168 /** 169 * Returns 0 after EOF has been reached, otherwise always return 1. 170 * <p> 171 * Programs should not count on this method to return the actual number 172 * of bytes that could be read without blocking. 173 * 174 * @return 1 before EOF and 0 after EOF. 175 * @exception IOException if an I/O error occurs. 176 * 177 */ 178 public int available() throws IOException { 179 ensureOpen(); 180 if (reachEOF) { 181 return 0; 182 } else if (inf.finished()) { 183 // the end of the compressed data stream has been reached 184 reachEOF = true; 185 return 0; 186 } else { 187 return 1; 188 } 189 } 190 191 private byte[] b = new byte[512]; 192 193 /** 194 * Skips specified number of bytes of uncompressed data. 195 * @param n the number of bytes to skip 196 * @return the actual number of bytes skipped. 197 * @exception IOException if an I/O error has occurred 198 * @exception IllegalArgumentException if {@code n < 0} 199 */ 200 public long skip(long n) throws IOException { 201 if (n < 0) { 202 throw new IllegalArgumentException("negative skip length"); 203 } 204 ensureOpen(); 205 int max = (int)Math.min(n, Integer.MAX_VALUE); |