/** * Retrieve a single byte from the decoded characters buffer. * * @return The decoded character or -1 if there was an EOF condition. */ private int getByte() throws IOException { if (!dataAvailable() && !decodeStreamData()) { return -1; } decodedCount--; // we need to ensure this doesn't get sign extended return decodedChars[decodedIndex++] & 0xff; }
/** * Retrieve a single byte from the decoded characters buffer. * * @return The decoded character or -1 if there was an EOF condition. */ private int getByte() throws IOException { if (!dataAvailable() && !decodeStreamData()) { return -1; } decodedCount--; // we need to ensure this doesn't get sign extended return decodedChars[decodedIndex++] & 0xff; }
private int getBytes(byte[] data, int offset, int length) throws IOException { int readCharacters = 0; while (length > 0) { // need data? Try to get some if (!dataAvailable() && !decodeStreamData()) { // if we can't get this, return a count of how much we did get (which may be -1). return readCharacters > 0 ? readCharacters : -1; } // now copy some of the data from the decoded buffer to the target buffer int copyCount = Math.min(decodedCount, length); System.arraycopy(decodedChars, decodedIndex, data, offset, copyCount); decodedIndex += copyCount; decodedCount -= copyCount; offset += copyCount; length -= copyCount; readCharacters += copyCount; } return readCharacters; }
private int getBytes(byte[] data, int offset, int length) throws IOException { int readCharacters = 0; while (length > 0) { // need data? Try to get some if (!dataAvailable() && !decodeStreamData()) { // if we can't get this, return a count of how much we did get (which may be -1). return readCharacters > 0 ? readCharacters : -1; } // now copy some of the data from the decoded buffer to the target buffer int copyCount = Math.min(decodedCount, length); System.arraycopy(decodedChars, decodedIndex, data, offset, copyCount); decodedIndex += copyCount; decodedCount -= copyCount; offset += copyCount; length -= copyCount; readCharacters += copyCount; } return readCharacters; }