public class FileReader
extends java.lang.Object
Constructor and Description |
---|
FileReader(java.io.File file) |
FileReader(java.lang.String filePath) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the reader.
|
java.lang.String |
readFile()
Reads the entire file into a String
|
static java.lang.String |
readFile(java.io.File file)
Reads the entire file in as a String
|
static java.lang.String |
readFile(java.lang.String filePath)
Reads the entire file in as a String
|
java.lang.String |
readLine()
Reads a single line of the file
|
java.lang.String |
readRestOfFile()
Reads the rest of the file into a String
|
static java.lang.Object |
readSerializedFile(java.io.File file)
Reads the file and deserializes it into an Object
|
static java.lang.Object |
readSerializedFile(java.lang.String filePath)
Reads the file and deserializes it into an Object
|
void |
reopen()
Reopens the file, returning the the beginning
|
java.lang.String |
toString() |
public FileReader(java.io.File file) throws java.io.FileNotFoundException
file
- the file to read with this readerjava.io.FileNotFoundException
- if the file can't be foundpublic FileReader(java.lang.String filePath) throws java.io.FileNotFoundException
filePath
- the path of the file to read with this readerjava.io.FileNotFoundException
- if the file can't be foundpublic static java.lang.String readFile(java.io.File file) throws java.io.IOException
file
- the file to readjava.io.IOException
- if the file can't be openedpublic static java.lang.String readFile(java.lang.String filePath) throws java.io.IOException
filePath
- the path of the file to readjava.io.IOException
- if the file can't be openedpublic static java.lang.Object readSerializedFile(java.io.File file) throws java.io.IOException, java.lang.ClassNotFoundException
file
- the file to readjava.io.IOException
- if the file can't be openedjava.lang.ClassNotFoundException
- if the type of the serialized object can't be foundpublic static java.lang.Object readSerializedFile(java.lang.String filePath) throws java.io.IOException, java.lang.ClassNotFoundException
filePath
- the path of the file to readjava.io.IOException
- if the file can't be openedjava.lang.ClassNotFoundException
- if the type of the serialized object can't be foundpublic void close() throws java.io.IOException
java.io.IOException
- if the file has already been closedpublic java.lang.String readFile() throws java.io.IOException
java.io.IOException
- if the file can't be readpublic java.lang.String readLine() throws java.io.IOException
java.io.IOException
- if the next line can't be readpublic java.lang.String readRestOfFile() throws java.io.IOException
java.io.IOException
- if the file can't be readpublic void reopen() throws java.io.FileNotFoundException
java.io.FileNotFoundException
- if the file can't be reopenedpublic java.lang.String toString()
toString
in class java.lang.Object