|
|||||||||
| Home >> All >> org >> mitre >> [ cvw overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.mitre.cvw
Class FileHandler

java.lang.Objectorg.mitre.cvw.FileHandler
- public class FileHandler
- extends java.lang.Object
File system interface for Java Client. This class provides a generic file interface, regardless whether the file is text or binary. The file can either be opened for writing or reading, but not both (bad things happen). If opened for reading, only the read streams will be created. Likewise, only the write streams will be initialized if the file is opened for writing. Certain functions will be available depending on whether the file is text or binary.
For text files, the methods available are:
- writeFile(String)
- readFile()
- getLastRead()
- getFileSize()
- close()
- writeFile(byte[], int)
- readFile(int)
- getLastRead()
- getFileSize()
- close()
- Version:
- 1
| Field Summary | |
(package private) boolean |
binary_file
|
(package private) java.io.BufferedInputStream |
file_input
|
(package private) java.io.BufferedOutputStream |
file_output
|
(package private) int |
last_read
|
(package private) java.io.File |
open_file
|
(package private) java.io.BufferedReader |
text_input
|
(package private) java.io.PrintWriter |
text_output
|
(package private) boolean |
write_file
|
| Constructor Summary | |
FileHandler(java.lang.String path,
boolean binary,
boolean write_to_file)
Constructor |
|
| Method Summary | |
boolean |
close()
Closes any open streams |
boolean |
closeReader()
Closes any open reading streams |
boolean |
closeWriter()
Closes any open writer streams |
long |
getFileSize()
Get the size of the file that will be read |
int |
getLastRead()
Gets the size from the last read function (text or binary) |
(package private) void |
openReader()
method to set up the streams to read from a file |
(package private) void |
openWriter()
method to intialize the streams for writing to a file |
java.lang.String |
readFile()
Reads a line from a text file |
byte[] |
readFile(int size)
Reads a specified number of bytes from a binary file |
int |
writeFile(byte[] b,
int len)
Writes a specified number of bytes to a binary file |
int |
writeFile(java.lang.String line)
method for writing a string to a text file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
open_file
java.io.File open_file
file_input
java.io.BufferedInputStream file_input
file_output
java.io.BufferedOutputStream file_output
text_input
java.io.BufferedReader text_input
text_output
java.io.PrintWriter text_output
binary_file
boolean binary_file
write_file
boolean write_file
last_read
int last_read
| Constructor Detail |
FileHandler
public FileHandler(java.lang.String path, boolean binary, boolean write_to_file) throws java.io.FileNotFoundException, java.io.IOException
- Constructor
| Method Detail |
openReader
void openReader()
throws java.io.FileNotFoundException
- method to set up the streams to read from a file
openWriter
void openWriter()
throws java.io.IOException
- method to intialize the streams for writing to a file
close
public boolean close()
- Closes any open streams
closeReader
public boolean closeReader()
- Closes any open reading streams
closeWriter
public boolean closeWriter()
- Closes any open writer streams
writeFile
public int writeFile(java.lang.String line)
- method for writing a string to a text file.
The function will add a line break to the end of the string when written to the file
writeFile
public int writeFile(byte[] b,
int len)
- Writes a specified number of bytes to a binary file
readFile
public byte[] readFile(int size)
- Reads a specified number of bytes from a binary file
readFile
public java.lang.String readFile()
- Reads a line from a text file
getLastRead
public int getLastRead()
- Gets the size from the last read function (text or binary)
getFileSize
public long getFileSize()
- Get the size of the file that will be read
|
|||||||||
| Home >> All >> org >> mitre >> [ cvw overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.mitre.cvw.FileHandler