@Override public int read(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { if (position >= length) { return -1; } byte[] buffer = getBlock(); int bufferPos = (int) (position % BLOCK_SIZE); // Find maxIdx and simplify test in for-loop int maxLen = (int) Math.min(Math.min(pLength, buffer.length - bufferPos), length - position); int i; //for (i = 0; i < pLength && i < buffer.length - idx && i < length - position; i++) { for (i = 0; i < maxLen; i++) { pBytes[pOffset + i] = buffer[bufferPos + i]; } position += i; return i; }
@Override public int read(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { if (position >= length) { return -1; } byte[] buffer = getBlock(); int bufferPos = (int) (position % BLOCK_SIZE); // Find maxIdx and simplify test in for-loop int maxLen = (int) Math.min(Math.min(pLength, buffer.length - bufferPos), length - position); int i; //for (i = 0; i < pLength && i < buffer.length - idx && i < length - position; i++) { for (i = 0; i < maxLen; i++) { pBytes[pOffset + i] = buffer[bufferPos + i]; } position += i; return i; }
@Override public int read(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { if (mPosition >= mLength) { return -1; } byte[] buffer = getBlock(); int bufferPos = (int) (mPosition % BLOCK_SIZE); // Find maxIdx and simplify test in for-loop int maxLen = (int) Math.min(Math.min(pLength, buffer.length - bufferPos), mLength - mPosition); int i; //for (i = 0; i < pLength && i < buffer.length - idx && i < mLength - mPosition; i++) { for (i = 0; i < maxLen; i++) { pBytes[pOffset + i] = buffer[bufferPos + i]; } mPosition += i; return i; }
@Override public void write(final byte[] pBuffer, final int pOffset, final int pLength) throws IOException { byte[] buffer = getBlock(); for (int i = 0; i < pLength; i++) { int index = (int) mPosition % BLOCK_SIZE; if (index == 0) { buffer = getBlock(); } buffer[index] = pBuffer[pOffset + i]; mPosition++; } if (mPosition > mLength) { mLength = mPosition; } }
@Override public void write(final byte[] pBuffer, final int pOffset, final int pLength) throws IOException { byte[] buffer = getBlock(); for (int i = 0; i < pLength; i++) { int index = (int) position % BLOCK_SIZE; if (index == 0) { buffer = getBlock(); } buffer[index] = pBuffer[pOffset + i]; position++; } if (position > length) { length = position; } }
public int read() throws IOException { if (mPosition >= mLength) { return -1; } byte[] buffer = getBlock(); int idx = (int) (mPosition % BLOCK_SIZE); mPosition++; return buffer[idx] & 0xff; }
public void write(final int pByte) throws IOException { byte[] buffer = getBlock(); int idx = (int) (mPosition % BLOCK_SIZE); buffer[idx] = (byte) pByte; mPosition++; if (mPosition > mLength) { mLength = mPosition; } }
public void write(final int pByte) throws IOException { byte[] buffer = getBlock(); int idx = (int) (position % BLOCK_SIZE); buffer[idx] = (byte) pByte; position++; if (position > length) { length = position; } }
public int read() throws IOException { if (position >= length) { return -1; } byte[] buffer = getBlock(); int idx = (int) (position % BLOCK_SIZE); position++; return buffer[idx] & 0xff; }
@Override public void write(final byte[] pBuffer, final int pOffset, final int pLength) throws IOException { byte[] buffer = getBlock(); for (int i = 0; i < pLength; i++) { int index = (int) position % BLOCK_SIZE; if (index == 0) { buffer = getBlock(); } buffer[index] = pBuffer[pOffset + i]; position++; } if (position > length) { length = position; } }
public int read() throws IOException { if (position >= length) { return -1; } byte[] buffer = getBlock(); int idx = (int) (position % BLOCK_SIZE); position++; return buffer[idx] & 0xff; }
public void write(final int pByte) throws IOException { byte[] buffer = getBlock(); int idx = (int) (position % BLOCK_SIZE); buffer[idx] = (byte) pByte; position++; if (position > length) { length = position; } }