|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
java.io.PrintWriter
repast.simphony.integration.RandomAccessWriter
public class RandomAccessWriter
A PrintWriter that writes to a file channel, allowing it to do random access
types of writes. This supports a stack of marks (and therefore resets). It also allows for
jumping to offsets in the file, determining the current file offset, and truncating the file.
| Field Summary |
|---|
| Fields inherited from class java.io.PrintWriter |
|---|
out |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
RandomAccessWriter(File file)
Opens this writer on the specified file. |
|
RandomAccessWriter(String fileName)
Opens this writer on the specified file. |
|
| Method Summary | |
|---|---|
void |
close()
|
long |
getTrueOffset()
Retrieves the actual offset of the file, disregarding any buffering. |
void |
mark()
Adds a mark to the mark queue at the current location in the file. |
Long |
popMark()
Removes a mark from the mark queue and returns it. |
void |
position(long position)
Positions the file to the specified position. |
void |
reset()
This jumps the file offset back to the previously marked position. |
FileChannel |
truncate(long size)
Truncates the file to the specified size. |
FileChannel |
truncateToPosition()
Truncates the file to the current offset. |
| Methods inherited from class java.io.PrintWriter |
|---|
append, append, append, checkError, clearError, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RandomAccessWriter(File file)
throws FileNotFoundException
file - the file to write to
FileNotFoundException
public RandomAccessWriter(String fileName)
throws FileNotFoundException
fileName - the name of the file to open
FileNotFoundException| Method Detail |
|---|
public long getTrueOffset()
throws IOException
IOException
public void mark()
throws IOException
getTrueOffset(), this causes the underlying data stream to flush.
IOExceptionpublic Long popMark()
public void reset()
throws IOException
IOException
public void position(long position)
throws IOException
position - the position to set the write mark to
IOException
public FileChannel truncateToPosition()
throws IOException
truncate(long)
with the value from getTrueOffset().
IOException
public FileChannel truncate(long size)
throws IOException
size - the size to truncate the file to
IOExceptionpublic void close()
close in interface Closeableclose in class PrintWriter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||