public class TextFileBuffer extends java.lang.Object implements TextBuffer
| Constructor and Description |
|---|
TextFileBuffer()
Creates a new instance of TextFileBuffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLine(java.lang.String text)
Adds a line of text to the end of the buffer.
|
void |
appendToLine(int line,
java.lang.String text)
Appends text to the specified line.
|
void |
clear()
Clears the buffer.
|
java.lang.String |
getLine(int line)
Gets a specific line from the buffer.
|
int |
getSize()
Returns the number of lines in the buffer.
|
void |
insertLine(int line,
java.lang.String text)
Inserts a new line at the specified position.
|
void |
load(java.io.File file)
Loads a text file into the buffer.
|
void |
load(java.lang.String path)
Loads a text file into the buffer.
|
TextBuffer |
newInstance()
Returns a new instance of the buffer.
|
void |
removeLine(int line)
Removes the specified line.
|
void |
save()
Saves the buffer back to disk again.
|
void |
saveAs(java.io.File file)
Saves the buffer to another file.
|
void |
saveAs(java.lang.String path)
Saves the buffer to another file.
|
void |
setLine(int line,
java.lang.String text)
Replaces a specific line in the buffer.
|
void |
setReadOnly(boolean readOnly)
If true makes the buffer read only.
|
java.lang.String |
toString()
Returns the buffer as a String.
|
public void setReadOnly(boolean readOnly)
throws java.lang.UnsupportedOperationException
setReadOnly in interface TextBufferreadOnly - Set to true to make buffer read only. Defaults to false.java.lang.UnsupportedOperationExceptionpublic void load(java.io.File file)
throws java.io.IOException
file - The file to load.java.io.IOExceptionpublic void load(java.lang.String path)
throws java.io.IOException
load in interface TextBufferpath - The path to the file to load.java.io.IOExceptionpublic void save()
throws java.io.IOException
save in interface TextBufferjava.io.IOExceptionpublic void saveAs(java.io.File file)
throws java.io.IOException
file - The file to save to.java.io.IOExceptionpublic void saveAs(java.lang.String path)
throws java.io.IOException
saveAs in interface TextBufferpath - The path to the file to save to.java.io.IOExceptionpublic void clear()
clear in interface TextBufferpublic int getSize()
getSize in interface TextBufferpublic java.lang.String getLine(int line)
getLine in interface TextBufferline - The line to get.public void setLine(int line,
java.lang.String text)
setLine in interface TextBufferline - The line to replace.text - The new text for the line.public void removeLine(int line)
removeLine in interface TextBufferline - The line to remove.public void insertLine(int line,
java.lang.String text)
insertLine in interface TextBufferline - the poistion to insert at.text - The text to insert.public void appendToLine(int line,
java.lang.String text)
line - The line to add text to.text - The text to add.public void addLine(java.lang.String text)
addLine in interface TextBuffertext - The text to add.public TextBuffer newInstance()
newInstance in interface TextBufferpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2009-2012. All Rights Reserved.