Package steganography.audio
Class BitByteConverter
- java.lang.Object
-
- steganography.audio.BitByteConverter
-
public class BitByteConverter extends java.lang.Object
This class provides methods that make working with bits and bytes easier.- Author:
- Richard Rudek
-
-
Constructor Summary
Constructors Constructor Description BitByteConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte
bitsToByte(byte[] bits)
Converts 8 bits into a the byte they are representing.static byte[]
byteToBits(byte byteToConvert)
Converts a byte into an array with length 8 that contains the bit representation of that byte.static byte[][]
byteToBits(byte[] bytes)
Converts a byte array to a 2d-array containing the bit representation of each byte.
-
-
-
Method Detail
-
byteToBits
public static byte[][] byteToBits(byte[] bytes)
Converts a byte array to a 2d-array containing the bit representation of each byte. An empty array will be treated as a byte array containing only a zero.- Parameters:
bytes
- Byte array to convert into bits- Returns:
- Byte array:
First dimension = the number of the current byte
Second dimension = the bit representation for that byte - Throws:
java.lang.NullPointerException
- if the given byte array is null
-
byteToBits
public static byte[] byteToBits(byte byteToConvert)
Converts a byte into an array with length 8 that contains the bit representation of that byte.- Parameters:
byteToConvert
- Byte to convert into bits- Returns:
- Byte array - the bit representation for that byte
-
bitsToByte
public static byte bitsToByte(byte[] bits)
Converts 8 bits into a the byte they are representing.- Parameters:
bits
- Array of 8 bits to convert into a byte- Returns:
- byte - Byte representation of the bits
- Throws:
java.lang.IllegalArgumentException
- If the length of the array is not 8 or an element of the array is neither 0 nor 1java.lang.NullPointerException
- if the given array is null
-
-