Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
https://metanit.com/java/tutorial/6.3.php
String stringBits = "11111111";
byte oneByte = (byte) Integer.parseInt(stringBits , 2);
byte[] byteArray = new byte[1];
byteArray[0] = oneByte;
try (FileOutputStream fos = new FileOutputStream(PATH_OUT)) {
fos.write(byteArray, 0, byteArray.length);
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
Take java.util.BitSet, it has toByteArray() method, and write via ByteArrayOutputStream
- https://metanit.com/java/tutorial/6.4.php
PS. And don't forget about BigEndian/LittleEndian - https://en.wikipedia.org/wiki/%D0%9F%D0%BE%D1%80%D...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question