|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.pfl.basic.tools.file.FileWrapper
public class FileWrapper
File wrapper for text files. Makes it really easy to open, close, delete, read, and write text files.
| Nested Class Summary | |
|---|---|
static class |
FileWrapper.FileState
|
static class |
FileWrapper.OpenMode
|
| Constructor Summary | |
|---|---|
FileWrapper(File file)
Create a new FileWrapper for the given File. |
|
FileWrapper(File root,
String str)
|
|
FileWrapper(String str)
|
|
| Method Summary | |
|---|---|
boolean |
canWrite()
|
void |
close()
Close the file, and set its state to CLOSED. |
void |
copyTo(FileWrapper target,
byte[] buffer)
Copy this file to target using buffer to hold data. |
void |
delete()
|
String |
getAbsoluteName()
|
FileWrapper.FileState |
getFileState()
|
String |
getName()
|
void |
open(FileWrapper.OpenMode mode)
Open the (text) file for I/O. |
byte[] |
readAll()
|
String |
readLine()
Read the next line from the text file. |
String |
toString()
|
void |
writeAll(byte[] data)
|
void |
writeLine(String line)
Write the line to the end of the file, including a newline. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FileWrapper(File file)
file - File to wrappublic FileWrapper(String str)
public FileWrapper(File root,
String str)
| Method Detail |
|---|
public boolean canWrite()
public String toString()
toString in class Objectpublic void delete()
public String getName()
public String getAbsoluteName()
public byte[] readAll()
throws IOException
IOException
public void writeAll(byte[] data)
throws IOException
IOException
public String readLine()
throws IOException
IOException - for IO errors.
public void writeLine(String line)
throws IOException
line - The line to write.
IOException - for IO errors.public void close()
close in interface Closeable
public void open(FileWrapper.OpenMode mode)
throws IOException
mode - READ or WRITE mode.
IOException - for IO exceptions.public FileWrapper.FileState getFileState()
public void copyTo(FileWrapper target,
byte[] buffer)
throws IOException
target - The FileWrapper to copy data to.buffer - The buffer to use for copying the files.
IOException - for IO exceptions.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||