planty
Class FileHandler

java.lang.Object
  extended by planty.FileHandler

public class FileHandler
extends java.lang.Object

Handles save files.

Author:
Nereare

Field Summary
static java.lang.String ext
          The program's save file extension.
 
Constructor Summary
FileHandler()
           
 
Method Summary
private static void echo()
          Prints an empty line in the default PrintStream.
private static void echo(java.lang.Object o)
          Prints the given content.
private static void echoErr(java.lang.Object o)
          Prints something to the default error PrintStream.
static Sprouling load()
          Loads a plant from a file.
private static java.lang.String read()
          Executes a line-reading of the default InputStream.
private static int readInt()
          Runs the read() method and converts the input to int format.
static boolean save(Sprouling plant)
          Saves the given plant to a file.
private static boolean yes()
          Reades the default InputStream for an "yes" or "no".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ext

public static final java.lang.String ext
The program's save file extension.

See Also:
Constant Field Values
Constructor Detail

FileHandler

public FileHandler()
Method Detail

read

private static java.lang.String read()
Executes a line-reading of the default InputStream.

Returns:
either the data inputed to the command-line or null in case of error.

readInt

private static int readInt()
Runs the read() method and converts the input to int format.

Returns:
the user input as a integer number.

yes

private static boolean yes()
Reades the default InputStream for an "yes" or "no".

Returns:
false if the user input "n", true otherwise.

echo

private static void echo()
Prints an empty line in the default PrintStream.


echo

private static void echo(java.lang.Object o)
Prints the given content.

Parameters:
o - something to print.

echoErr

private static void echoErr(java.lang.Object o)
Prints something to the default error PrintStream.

Parameters:
o - the thing to print.

save

public static boolean save(Sprouling plant)
Saves the given plant to a file.

Parameters:
plant - the plant whose data is to be saved as a Sprouling object.
Returns:
true if file was successfully saved, false otherwise.

load

public static Sprouling load()
Loads a plant from a file.

Returns:
the plant as a Sprouling object.