/** Gets an array containing all bits written thus far. */ public byte[] toByteArray() { return this.writer.toByteArray(); }
/** Gets an array containing all bits written thus far. */ public byte[] toByteArray() { return this.writer.toByteArray(); }
BitBuffer bb = new BitBuffer(out.toByteArray()); for (int i=0; i<values.length; i++) { int value = bb.getBits(bits[i]); out.write(sb.toString()); LOGGER.info("Reading values from byte array"); bb = new BitBuffer(out.toByteArray()); for (int i = 0; i < 5000; i++) { int value = bb.getBits(1);
bw.write(nums[i], len[i]); BitBuffer bb = new BitBuffer(bw.toByteArray()); int readint; LOGGER.info("Reading from BitBuffer"); bb = new BitBuffer(bw.toByteArray()); bb = new BitBuffer(bw.toByteArray()); for (int i = 0; i < trials; i++) { int c = r.nextInt(100);
/** * The CodecOptions parameter must be an instance of * {@link HuffmanCodecOptions}, and should have the following fields set: * {@link HuffmanCodecOptions#table table} * {@link CodecOptions#bitsPerSample bitsPerSample} * {@link CodecOptions#maxBytes maxBytes} * * @see Codec#decompress(RandomAccessInputStream, CodecOptions) */ @Override public byte[] decompress(RandomAccessInputStream in, CodecOptions options) throws CodecException, IOException { if (in == null) throw new IllegalArgumentException("No data to decompress."); if (options == null || !(options instanceof HuffmanCodecOptions)) { throw new CodecException("Options must be an instance of " + "ome.codecs.HuffmanCodecOptions."); } HuffmanCodecOptions huffman = (HuffmanCodecOptions) options; int nSamples = (huffman.maxBytes * 8) / huffman.bitsPerSample; int bytesPerSample = huffman.bitsPerSample / 8; if ((huffman.bitsPerSample % 8) != 0) bytesPerSample++; BitWriter out = new BitWriter(); for (int i=0; i<nSamples; i++) { int sample = getSample(in, options); out.write(sample, bytesPerSample * 8); } return out.toByteArray(); }