How can I write a byte array to a file in Java?

Viewed 148724

How to write a byte array to a file in Java?

8 Answers
         File file = ...
         byte[] data = ...
         try{
            FileOutputStream fos = FileOutputStream(file);
            fos.write(data);
            fos.flush();
            fos.close();
         }catch(Exception e){
          }

but if the bytes array length is more than 1024 you should use loop to write the data.

Related