/** 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 */ /** Generate a test data file. The size is a multiple of 4096 bytes. Depending on the options, you can generate two types of output. With option "-a", the output will be set so that when interpreted as ASCII characters, it will look like a series of: [space][letter][space][space]. With option "-b", the records are short ints, with each record having a value less than 30,000. */ import java.io.*; import java.util.*; import java.math.*; public class Genfile2 { static final int BlockSize = 4096; static final int NumRecs = 2048; // Because they are short ints /** Initialize the random variable */ static private Random value = new Random(); // Hold the Random class object static int random(int n) { return Math.abs(value.nextInt()) % n; } public static void main(String args[]) throws IOException { short val; if ((args.length != 3) || (args[0].charAt(0) != '-')) { System.out.println("Usage: Genfile2