// Source code example for "A Practical Introduction // to Data Structures and Algorithm Analysis" // by Clifford A. Shaffer, Prentice Hall, 1998. // Copyright 1998 by Clifford A. Shaffer import java.io.*; // A simple test program for Binary File I/O // For a file of numbers, read in a series of blocks // making up the file. For each block, interpret // the byte stream as a series of int variables. // Write it out by reversing this conversion process. // Take as input a file generated by "Genfile". public class Test { static final int NumRec = 256; public static void main(String args[]) throws IOException { byte[] buf = new byte[4*NumRec]; int[] intbuf = new int[NumRec]; Assert.notFalse(args.length == 2, "Usage: Test \nSize is measured in blocks of 4096 bytes"); int filesize = Integer.parseInt(args[1]); RandomAccessFile in = new RandomAccessFile(args[0], "r"); RandomAccessFile out = new RandomAccessFile("dum.out", "rw"); for (int blocks=0; blocks