Java Reference
In-Depth Information
file was placed in the filesystem based on a String set during construction that we called the
filePrefix . The intuition was that we would use the filePrefix field to identify the direct-
ory that would contain the file named with the player's unique ID. To refresh your memory,
here is the code as we left it before:
package org.oreilly.javaGoodParts.examples.impl;
import java.util.UUID;
import org.oreilly.javaGoodParts.examples.statistics.Player;
import org.oreilly.javaGoodParts.examples.statistics.Team;
public class PlayerImpl implements Player, Serializable {
private static final long serialVersionUID = 1;
private UUID id;
private String name;
private String filePrefix;
private Team team;
private Position pos = Position.Utility;
private boolean changed = false;
public PlayerImpl(String playerName) {
name = playerName;
id = UUID.randomUUID();
public PlayerImpl(UUID playerId, String prefix) {
id = playerId;
filePrefix = prefix;
try {
ObjectInputStream readIn = new ObjectInputStream(
new FileInputStream(prefix + id.toString()));
PlayerImpl copy = (PlayerImpl) readIn.readObject();
id = playerId;
Search WWH ::

Custom Search