Mit den Klassen FileInputStream und FileOutputStream.
// Datei lesen
try (FileInputStream inputStream = new FileInputStream("input.bin")) {
int byteRead;
while ((byteRead = inputStream.read()) != -1) {
System.out.print(byteRead + " ");
}
} catch (IOException e) {
e.printStackTrace();
}
// Datei schreiben
try (FileOutputStream outputStream = new FileOutputStream("output.bin")) {
byte[] data = { 65, 66, 67, 68, 69 }; // Example data
outputStream.write(data);
} catch (IOException e) {
e.printStackTrace();
}