bsharp.fileio
Class EasyFile

java.lang.Object
  extended by java.io.File
      extended by bsharp.fileio.EasyFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.io.File>

public class EasyFile
extends java.io.File

A helper class to reading a writing files.

Author:
brandon@sharpideas.ca
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
EasyFile(java.io.File _file)
          Create helper class given the filename.
EasyFile(java.lang.String _filename)
          Create helper class given the filename.
 
Method Summary
 void closeAfterRead()
          close file after writing.
 void closeAfterWrite()
          close file after writing.
 void openForReading()
          Open a file for reading.
 void openForWriting()
          Open a file for writing.
 void openForWriting(boolean append)
          Open a file for writing.
 java.lang.String readLine()
          Read a line from the file.
 void write(java.lang.String s)
          Write to the file.
 void writeln(java.lang.String s)
          Write to the file.
 
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EasyFile

public EasyFile(java.lang.String _filename)
Create helper class given the filename.

Parameters:
filename - the file that may be written or read.

EasyFile

public EasyFile(java.io.File _file)
Create helper class given the filename.

Parameters:
filename - the file that may be written or read.
Method Detail

openForReading

public void openForReading()
Open a file for reading.

Parameters:
name -

openForWriting

public void openForWriting()
Open a file for writing.


openForWriting

public void openForWriting(boolean append)
Open a file for writing.

Parameters:
append - if true then append to the end of the file.

write

public void write(java.lang.String s)
Write to the file. Must call openForWriting() first.

Parameters:
s -

writeln

public void writeln(java.lang.String s)
Write to the file. Must call openForWriting() first.

Parameters:
s -

readLine

public java.lang.String readLine()
Read a line from the file. Must call openForReading() first.

Returns:

closeAfterRead

public void closeAfterRead()
close file after writing. The partner to openForReading().


closeAfterWrite

public void closeAfterWrite()
close file after writing. The partner to openForWriting().