Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. package ex2binaryfile;
  2.  
  3. import java.io.*;
  4. public class Ex2BinaryFile {
  5.  
  6. public static void main(String[] args) throws IOException {
  7.         try (
  8.             // Create an output stream to the file
  9.             // Append new data if file already exists
  10.             FileOutputStream output =
  11.                 new FileOutputStream("Ex2BinaryFile.dat", true);
  12.         ) {
  13.             // Output 100 integers created randomly into the file
  14.             for (int i = 0; i < 100; i++)
  15.                 output.write((int)(1 + Math.random() * 100));
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement