Java Reference
In-Depth Information
gives the name of the winning car. Have the logging message use
the SimpleFormatter and the ConsoleHandler.
3. Write a program named ShowWinners that displays all of the win-
ners in the winners.dat file, using the corresponding input streams
or reader classes.
Each time you run the Race program, the winner is added to the end of
the winners.dat file and an INFO log message should appear at the con-
sole output. Running the ShowWinner program should display all the
entries in the file.
Lab 16.3: Using Serialization
In this lab, you will write a class that is serializable. The class will repre-
sent an instant message and will be used as part of the Instant Messaging
project you started in Chapter 12.
1. Write a class named InstantMessage, making it serializable.
2. Add three private String fields: recipient, sender, and message.
3. Add a constructor that takes in three String parameters that are used
to initialize the three fields.
4. Add three accessor methods, one for each of the three fields.
5. Save and compile your InstantMessage class.
You shouldn't see anything yet. You will use this class in the next lab.
Lab 16.4: Using Pipes
In this lab, you will become familiar with using pipes to perform I/O
between two threads You will modify the SendMessage listener class
from Lab 13.3.
1. Open your SendMessage.java file from Lab 13.3. Add a field of type
ObjectOutputStream and a String to represent the sender.
2. Add an OutputStream parameter and String parameter (for the
sender field) to the constructor of SendMessage. Initialize the
ObjectOutputStream field by chaining the OutputStream parameter
to a new ObjectOutputStream.
Search WWH ::




Custom Search