Write a program similar to the one in Listing 10.10 that can write an arbitrary number of

Question:

Write a program similar to the one in Listing 10.10 that can write an arbitrary number of Species objects to a binary file. (Species appears in Listing 5.19 of Chapter 5.) Read the file name and the data for the objects from a text file that you create by using a text editor. Then write another program that can search a binary file created by your first program and show the user the data for any requested endangered species. The user gives the file name and then enters the name of the species. The program either displays all the data for that species or gives a message if that species is not in the file. Allow the user to either enter additional species’ names or quit.


Listing 10.10

import java.io.FileInputStream; import java.io.FileOutputStream; i mport java.io.I0Exception; import java.io.ObjectInputStream; i mport java.io.0bject0utputStream; public class ClassObjectI0Demo { public static void main(String[]args) { ObjectoutputStream outputStream = null; String fileName =


Listing 5.19

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: