|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--TextFile
A TextFile mimics the sort of text file that one finds on a computer's file system. It has an owner, a create date (when the file was created), a modification date (when the file was last modified), and String contents.
Constructor Summary | |
TextFile(String owner,
String contents)
Construct a new TextFile with given owner and contents; set the creation and modification dates. |
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 file. |
String |
getCreateDate()
The data and time of the file's creation. |
String |
getModDate()
The date and time of the file's last modification. |
String |
getOwner()
The file's owner. |
int |
getSize()
The size of a file. |
static void |
main(String[] args)
A definition of main(), used only for testing this class. |
void |
setContents(String contents)
Replace the contents of the file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TextFile(String owner, String contents)
owner
- the user who owns the file.contents
- the file's initial contents.Method Detail |
public void append(String text)
text
- the text to be appended.public void appendLine(String text)
text
- the text to be appended.public String getContents()
public String getCreateDate()
public String getModDate()
public String getOwner()
public int getSize()
public static void main(String[] args)
%> java TextFileproduces the output:
TextFile myTextFile contains 13 characters. Created by bill, Sat Dec 29 14:02:37 EST 2001 Hello, world. append new line "How are you today?" Hello, world. How are you today? TextFile myTextFile contains 32 characters. Modified Sat Dec 29 14:02:38 EST 2001
public void setContents(String contents)
contents
- the new contents.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |