Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.Arrays;
- class Main {
- //Guardar
- public static void main(String[] args) {
- byte data[] = {1,1,1,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,00,0,0,1,0,1,0,1,1,1,1,0,0,1,1,1,0,1,1,1,1,0,0,1};
- System.out.println(Arrays.toString(data));
- try {
- FileOutputStream fos = new FileOutputStream("salida.bin");
- fos.write(data);
- fos.close();
- }
- catch(IOException e) {
- e.getStackTrace();
- }
- //Leer
- try{
- File fin = new File("salida.bin");
- FileInputStream finstream = new FileInputStream(fin);
- byte[] dataIn = new byte[(int) fin.length()];
- finstream.read(dataIn);
- finstream.close();
- System.out.println(Arrays.toString(dataIn));
- }
- catch(IOException e) {
- e.getStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement