Advertisement
eyitsmerubi

no idea java file io

Dec 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. package cmpe211lab7hw3;
  2.  
  3. import java.io.*;
  4.  
  5. public class Ugur {
  6.  
  7.     public static void main(String args[]) throws IOException {  
  8.         FileOutputStream out = null;
  9.        
  10.         int[] arr = new int[100];
  11.        
  12.         for (int i = 0; i < 100; ++i) {
  13.             arr[i] = (int) (Math.random() * 101);
  14.         }
  15.  
  16.         try {
  17.             out = new FileOutputStream("Example.txt");
  18.             int c;
  19.             for (int i = 0; i < 100; ++i) {
  20.                 out.write(arr[i]);
  21.             }
  22.         } finally {
  23.              if (out != null) {
  24.                 out.close();
  25.              }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement