Copyright © T. H. Merrett 308-420A Secondary Storage Algorithms and Data Structures Assignment 1: study and run the following program. Do not hand this in. (Put it in file asst1420.java Compile it by javac asst1420.java Run it by java asst1420 Make sure your .login file contains the line setenv CLASSPATH .:/course/cs420/java ) /* assignment 1: read 11 records of tbook, using read/write with char */ import java.io.*; public class asst1420 { public static void main(String[] args) { byte[] tbookint = new byte[81]; String wholeRec, name, address, phone; try { DataInputStream tbookd = new DataInputStream(new BufferedInputStream( new FileInputStream("/home/course/cs420/data/tbook"),891)); for(int n=0; n<11; n++){ tbookd.readFully(tbookint, 0, 81); wholeRec = byte2string(tbookint); name = wholeRec.substring(0,40); address = wholeRec.substring(40,73); phone = wholeRec.substring(73,80); System.out.println("name= " + name + ";\naddress= " + address + ";phone= " + phone + ";"); } tbookd.close(); } catch(IOException e) { System.out.print("Error: " + e); System.exit(1); } } static String byte2string(byte[] b) { int i; String s=""; for(i=0; i<b.length; i++) s = s + (char) b[i]; return s; } // this function is also found in class bytechars } Assignment 1a (also not to hand in): Replace the statement DataInputStream tbookd = new DataInputStream(new BufferedInputStream( new FileInputStream("/course/cs420/data/tbook"),891)); by the statements HostClient self= new HostClient("mimi"); FileClient tbookd = new FileClient(self, "tbook", "SEQ", 81); and compare the results. You may get Error: java.net.ConnectException: Connection refused If so, try cd ~cs420/java; java FileServer & then cd back to where you were and try again. How do the speeds compare between the two versions of the program? Try running the second program on your own computer instead of on a SOCS teaching machine (without first transferring the data file, "tbook"). You will need to copy and compile /course/cs420/java/HostClient.java in a suitable directory on your computer first. Try telnet mimi 8187 from your machine and try to figure out what is happening. It will help you to look at the source code in ~cs420/java/FileServer.java