bis = new Base64.InputStream( new java.io.BufferedInputStream( new java.io.FileInputStream(file)), Base64.DECODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes;
bis = new Base64.InputStream( new java.io.BufferedInputStream( new java.io.FileInputStream(file)), Base64.ENCODE); while ((numBytes = bis.read(buffer, length, 4096)) >= 0) { length += numBytes;
/** * Calls {@link #read()} repeatedly until the end of stream is reached or <var>len</var> bytes are read. * * <p>Returns number of bytes read into array or -1 if end of stream is encountered. * * {@inheritDoc} * * @param dest array to hold values * @param off offset for array * @param len max number of bytes to read into array * @return bytes read into array or -1 if end of stream is encountered. * @since 1.3 */ @Override public int read(byte[] dest, int off, int len) throws IOException { int i; int b; for (i = 0; i < len; i++) { b = read(); if (b >= 0) { dest[off + i] = (byte) b; } else if (i == 0) return -1; else { break; // Out of 'for' loop } } return i; }