7
I need to record some booleans in a File, and then retrieve them. I can record and read one or more bytes with the Classes java.io.FileInputStream
and java.io.FileOutputStream
, so I need to convert 1 byte to an array of 8 booleans, and, the conversion of an array of 8 booleans to 1 byte, so:
public static boolean[] byteToBooleanArray(byte b) {
boolean[] array = new boolean[8];
//O que colocar aqui?
return array;
}
public static byte booleanArrayToByte(boolean[] array) {
if (array.length != 8) throw new IllegalArgumentException();
byte b;
//O que colocar aqui?
return b;
}
Note: I wish I didn’t have to download a library.
Interesting problem yours. + 1
– user28595