import java.io.*; public class Binary_vs_Text_Files { public static void main(String[] args) throws IOException{ int [] nums = new int [20]; for (int i=0; i<nums.length; i++) { nums[i] = (int)(Math.random()*Integer.MAX_VALUE); } PrintWriter pw = new PrintWriter(new FileOutputStream("text.txt")); DataOutputStream os = new DataOutputStream(new FileOutputStream("binary.bin")); for (int n : nums) { pw.print(n + " "); os.writeInt(n); } pw.println(); pw.close(); os.close(); } }