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 TextBuffer
readOnly
- Set to true to make buffer read only. Defaults to false.java.lang.UnsupportedOperationException
public void load(java.io.File file) throws java.io.IOException
file
- The file to load.java.io.IOException
public void load(java.lang.String path) throws java.io.IOException
load
in interface TextBuffer
path
- The path to the file to load.java.io.IOException
public void save() throws java.io.IOException
save
in interface TextBuffer
java.io.IOException
public void saveAs(java.io.File file) throws java.io.IOException
file
- The file to save to.java.io.IOException
public void saveAs(java.lang.String path) throws java.io.IOException
saveAs
in interface TextBuffer
path
- The path to the file to save to.java.io.IOException
public void clear()
clear
in interface TextBuffer
public int getSize()
getSize
in interface TextBuffer
public java.lang.String getLine(int line)
getLine
in interface TextBuffer
line
- The line to get.public void setLine(int line, java.lang.String text)
setLine
in interface TextBuffer
line
- The line to replace.text
- The new text for the line.public void removeLine(int line)
removeLine
in interface TextBuffer
line
- The line to remove.public void insertLine(int line, java.lang.String text)
insertLine
in interface TextBuffer
line
- 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 TextBuffer
text
- The text to add.public TextBuffer newInstance()
newInstance
in interface TextBuffer
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2009-2012. All Rights Reserved.