/** Source code example for "A Practical Introduction to Data Structures and Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright 2008-2011 by Clifford A. Shaffer */ import java.io.*; public class Genfile { static final int NumRec = 1024; public static void main(String args[]) throws IOException { assert (args.length == 2) || (args.length == 3) : "Usage: Genfile [+/-]\nSize is measured in blocks of 4096 bytes"; int filesize = Integer.parseInt(args[1]); DataOutputStream file = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(args[0]))); int recs = 1024 * filesize - 1; if (args.length == 2) // Write out random numbers for (int i=0; i