public class FileWrapper
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
FileWrapper.FileState |
static class |
FileWrapper.OpenMode |
| Constructor and Description |
|---|
FileWrapper(java.io.File file)
Create a new FileWrapper for the given File.
|
FileWrapper(java.io.File root,
java.lang.String str) |
FileWrapper(java.lang.String str) |
| Modifier and Type | Method and Description |
|---|---|
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() |
java.lang.String |
getAbsoluteName() |
FileWrapper.FileState |
getFileState() |
java.lang.String |
getName() |
void |
open(FileWrapper.OpenMode mode)
Open the (text) file for I/O.
|
byte[] |
readAll() |
java.lang.String |
readLine()
Read the next line from the text file.
|
java.lang.String |
toString() |
void |
writeAll(byte[] data) |
void |
writeLine(java.lang.String line)
Write the line to the end of the file, including a newline.
|
public FileWrapper(java.io.File file)
file - File to wrappublic FileWrapper(java.lang.String str)
public FileWrapper(java.io.File root,
java.lang.String str)
public boolean canWrite()
public java.lang.String toString()
toString in class java.lang.Objectpublic void delete()
public java.lang.String getName()
public java.lang.String getAbsoluteName()
public byte[] readAll()
throws java.io.IOException
java.io.IOExceptionpublic void writeAll(byte[] data)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String readLine()
throws java.io.IOException
java.io.IOException - for IO errors.public void writeLine(java.lang.String line)
throws java.io.IOException
line - The line to write.java.io.IOException - for IO errors.public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic void open(FileWrapper.OpenMode mode) throws java.io.IOException
mode - READ or WRITE mode.java.io.IOException - for IO exceptions.public FileWrapper.FileState getFileState()
public void copyTo(FileWrapper target, byte[] buffer) throws java.io.IOException
target - The FileWrapper to copy data to.buffer - The buffer to use for copying the files.java.io.IOException - for IO exceptions.