Class TextFile

java.lang.Object
  |
  +--JFile
        |
        +--TextFile

public class TextFile
extends JFile

A TextFile is a JFile that holds text.

Version:
6

Field Summary
 
Fields inherited from class JFile
separator
 
Constructor Summary
TextFile(String name, User creator, Directory parent, String initialContents)
          Construct a TextFile with initial contents.
 
Method Summary
 void append(String text)
          Append text to the end of the file.
 void appendLine(String text)
          Append a new line of text to the end of the file.
 String getContents()
          The contents of a text file.
 int getSize()
          The size of a text file is the number of characters stored.
 String getSuffix()
          Suffix used for printing text file names is "".
 void setContents(String contents)
          Replace the contents of the file.
 
Methods inherited from class JFile
getCreateDate, getModDate, getName, getOwner, getParent, getPathName, isRoot, setModDate, setOwner, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextFile

public TextFile(String name,
                User creator,
                Directory parent,
                String initialContents)
Construct a TextFile with initial contents.

Parameters:
name - the name for this TextFile (in its parent Directory)
creator - the owner of this new TextFile
parent - the Directory in which this TextFile lives.
initialContents - the initial text
Method Detail

append

public void append(String text)
Append text to the end of the file.

Parameters:
text - the text to be appended.

appendLine

public void appendLine(String text)
Append a new line of text to the end of the file.

Parameters:
text - the text to be appended.

getContents

public String getContents()
The contents of a text file.

Returns:
String contents of the file.

getSize

public int getSize()
The size of a text file is the number of characters stored.

Specified by:
getSize in class JFile
Returns:
the file's size.

getSuffix

public String getSuffix()
Suffix used for printing text file names is "".

Specified by:
getSuffix in class JFile
Returns:
an empty suffix (for TextFiles).

setContents

public void setContents(String contents)
Replace the contents of the file.

Parameters:
contents - the new contents.