-
Notifications
You must be signed in to change notification settings - Fork 28
BitUtils
Julien Millau edited this page Aug 5, 2017
·
6 revisions
This class provided methods to write Integer, String, boolean, byte array with a custom size for these Java types.
Parameters of all methods are not checked.
Write bit
BitUtils bits = BitUtils(32); // create a byte array of 4 byte
bits.setNextBoolean(true); // write a boolean in 1 bit
bits.setNextInteger(95,7); // write the 95 value on 7 bit
bits.setNextString("foo"); // write "foo" on 3 bytes
byte[] data = bits.getData(); // getData
Read bit
byte[] array = new byte[]{0x88,0x30,0x40};
BitUtils bits = BitUtils(array); // import the array to the BitUtils object
boolean bool = bits.getNextBoolean(); // return true
int value = bits.getNextInteger(15); // return 8
Others methods
* boolean getNextBoolean()
* byte[] getNextByte(final int pSize)
* Date getNextDate(final int pSize, final String pPattern)
* String getNextHexaString(final int pSize)
* int getNextInteger(final int pLenght)
* int getNextIntegerSigned(final int pLength)
* long getNextLong(final int pLength)
* long getNextLongSigned(final int pLength)
* String getNextString(final int pSize)
* String getNextString(final int pSize, final Charset pCharset)
* reset() // Reset the current bit index to the initial position
* setCurrentBitIndex(final int pCurrentBitIndex)
* setNextBoolean(final boolean pBoolean)
* setNextByte(final byte[] pValue, final int pLenght)
* setNextDate(final Date pValue, final String pPattern)
* setNextHexaString(final String pValue, final int pLenght)
* setNextInteger(final int pValue, final int pLenght)
* setNextLong(final long pValue, final int pLength)
* setNextString(final String pValue)