Java Reference
In-Depth Information
name =;
team =;
pos = copy.pos;
} catch (IOException e) {
"unable to open file for player, creating new player object");
name = "unknown";
} catch (ClassNotFoundException e) {
System.out.println("unable to read file for player");
protected void writeState() {
try {
Integer playerId = id;
ObjectOutputStream writeOut =
new ObjectOutputStream(new FileOutputStream(filePrefix +
changed = false;
} catch (Exception e) {
System.out.println("unable to write object");
protected void finalize(){
if (changed){
"writing state in finalizer");
The problem with this is that most filesystems are hierarchical, so you have a set of directory
names that traverse the hierarchy to the point where files are stored. Part of this hierarchy is a
separator character, which is used to separate the name of one directory from that of another.
And these separator characters can (and do) differ from operating system to operating system.
Since the filePrefix string will almost certainly contain a number of occurrences of the file
separator character, how do we ensure that it will be the right character for the operating sys-
tem on which the program is running?
Search WWH ::

Custom Search