JBBPBitInputStream extends FilterInputStream implements JBBPCountableBitStream { public String readString(final JBBPByteOrder byteOrder) throws IOException { final int prefix = this.readByte(); final int len; if (prefix == 0) { len = 0; } else if (prefix == 0xFF) { len = -1; } else if (prefix < 0x80) { len = prefix; } else if ((prefix & 0xF0) == 0x80) { switch (prefix & 0x0F) { case 1: { len = this.readByte(); } break; case 2: { len = this.readUnsignedShort(byteOrder); } break; case 3: { int buffer; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { buffer = (this.readByte() << 16) | (this.readByte() << 8) | this.readByte(); } else { buffer = this.readByte() | (this.readByte() << 8) | (this.readByte() << 16); } len = buffer; } break; case 4: { len = this.readInt(byteOrder); } break; default: { throw makeIOExceptionForWrongPrefix(prefix); } } } else { throw makeIOExceptionForWrongPrefix(prefix); } final String result; if (len < 0) { result = null; } else if (len == 0) { result = ""; } else { result = JBBPUtils.utf8ToStr(this.readByteArray(len)); } return result; } JBBPBitInputStream(final InputStream in);  JBBPBitInputStream(final InputStream in, final JBBPBitOrder order); boolean[] readBoolArray(final int items); byte[] readBitsArray(final int items, final JBBPBitNumber bitNumber); byte[] readByteArray(final int items); byte[] readByteArray(final int items, final JBBPByteOrder byteOrder); short[] readShortArray(final int items, final JBBPByteOrder byteOrder); char[] readUShortArray(final int items, final JBBPByteOrder byteOrder); int[] readIntArray(final int items, final JBBPByteOrder byteOrder); float[] readFloatArray(final int items, final JBBPByteOrder byteOrder); long[] readLongArray(final int items, final JBBPByteOrder byteOrder); double[] readDoubleArray(final int items, final JBBPByteOrder byteOrder); int readUnsignedShort(final JBBPByteOrder byteOrder); int readInt(final JBBPByteOrder byteOrder); float readFloat(final JBBPByteOrder byteOrder); long readLong(final JBBPByteOrder byteOrder); double readDouble(final JBBPByteOrder byteOrder); @Override long getCounter(); @Override int getBitBuffer(); @Override int getBufferedBitsNumber(); @Override JBBPBitOrder getBitOrder(); byte readBitField(final JBBPBitNumber numOfBitsToRead); int readBits(final JBBPBitNumber numOfBitsToRead); boolean readBoolean(); int readByte(); @Override synchronized void reset(); @Override synchronized void mark(final int readlimit); void align(final long alignByteNumber); @Override long skip(final long numOfBytes); void alignByte(); boolean hasAvailableData(); @SuppressWarnings("NullableProblems") @Override int read(final byte[] array, final int offset, final int length); @Override void resetCounter(); @SuppressWarnings("NullableProblems") @Override int read(final byte[] array); @Override int read(); String readString(final JBBPByteOrder byteOrder); String[] readStringArray(final int items, final JBBPByteOrder byteOrder);  }
@Test public void testReadString_BigEndan_Null() throws Exception { assertEquals(null, asInputStream(0xFF).readString(JBBPByteOrder.BIG_ENDIAN)); }
@Test public void testReadString_BigEndan_Empty() throws Exception { assertEquals("", asInputStream(0x00).readString(JBBPByteOrder.BIG_ENDIAN)); }
@Test public void testReadString_BigEndan_ShortString() throws Exception { assertEquals("ABC", asInputStream(0x03, 65, 66, 67).readString(JBBPByteOrder.BIG_ENDIAN)); }
@Test public void testReadString_BigEndan_Msb0_ShortString() throws Exception { assertEquals("zzzz", asInputStreamMSB0(0x20, '^', '^', '^', '^').readString(JBBPByteOrder.BIG_ENDIAN)); }
@Test public void testReadString_LittleEndan_Null() throws Exception { assertEquals(null, asInputStream(0xFF).readString(JBBPByteOrder.LITTLE_ENDIAN)); }
@Test public void testReadString_LittleEndian_Empty() throws Exception { assertEquals("", asInputStream(0x00).readString(JBBPByteOrder.LITTLE_ENDIAN)); }
@Test public void testReadString_LittleEndian_ShortString() throws Exception { assertEquals("ABC", asInputStream(0x03, 65, 66, 67).readString(JBBPByteOrder.LITTLE_ENDIAN)); }