|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface VfsFile
Address and handle for a file in a Vfs.
Vfs systems consist of a hierarchy of VFSDirectories, some of which may contain VFSFiles. A VfsFile is a container of byte and/or text data. You can access it using streams or via direct convenience methods.
Actual VfsFile objects are implemented by a specific VFSModule.
Many of the methods here are convenience methods that should generally simply
wrap other methods. AbstractVfsFile implements
many of these for you, so you should generally extend that class rather than
implementing this interface.
Copyright 2006 Partner Software, Inc.
| Method Summary | |
|---|---|
void |
appendBytes(byte[] bytes)
Appends the given bytes to the file. |
void |
appendText(java.lang.String text)
Appends the given text to the end of the file. |
long |
checksum()
Generates a CRC32 checksum for the file's contents. |
VfsFile |
copyTo(Path newPath)
Copies the file to the new path. |
VfsFile |
copyTo(VfsFile destination)
Copies the file to the given VfsFile. |
java.io.BufferedOutputStream |
createAppendingBufferedOutputStream()
Creates a buffered output stream to write to the file. |
java.io.BufferedWriter |
createAppendingBufferedWriter()
Creates a buffered writer to write to the file. |
java.io.OutputStream |
createAppendingOutputStream()
Creates an output stream to append to the file. |
java.io.Writer |
createAppendingWriter()
Creates a writer to append text to the file. |
java.io.BufferedInputStream |
createBufferedInputStream()
Creates a buffered input stream to read from the file. |
java.io.BufferedOutputStream |
createBufferedOutputStream()
Creates a buffered output stream to write to the file. |
java.io.BufferedReader |
createBufferedReader()
Creates a buffered reader to read from the file. |
java.io.BufferedWriter |
createBufferedWriter()
Creates a buffered writer to write to the file. |
java.io.InputStream |
createInputStream()
Creates an input stream to read from the file. |
java.io.OutputStream |
createOutputStream()
Creates an output stream to write to the file. |
VfsRandomAccess |
createRandomAccess()
Creates a random access handle for the file. |
java.io.Reader |
createReader()
Creates a reader to read text from the file. |
java.io.Writer |
createWriter()
Creates a writer to write to the file. |
DateAndTime |
getLastModified()
Returns the date and time the file was last modified. |
long |
getLastModifiedMillis()
Returns the timestamp in milliseconds that the file was last modified. |
VfsFile |
moveTo(Path newPath)
Moves the file to the new path. |
VfsFile |
moveTo(VfsFile destination)
Moves the file to the given VfsFile. |
byte[] |
readBytes()
Reads the entire file in as a byte array. |
java.lang.String |
readText()
Read the contents of the file as text into a String. |
java.util.List<java.lang.String> |
readTextAsLines()
Read the contents of the file as text into a list of Strings, separated by line. |
java.lang.String |
readTextRange(long start,
long end)
Returns the text from the given start (inclusive) to the given end (exclusive), in characters. |
void |
regexReplace(java.util.List<java.lang.String> replacements)
Does a regular-expression-based text replacement on the entire file. |
void |
regexReplace(java.lang.String... replacements)
Does a regular-expression-based text replacement on the entire file. |
void |
remove()
Removes the file. |
VfsFile |
renameTo(java.lang.String name)
Renames the file. |
void |
setLastModified(DateAndTime newLast)
If possible, sets the date and time the file was last modified. |
void |
setLastModifiedMillis(long millis)
If possible, sets the date and time the file was last modified in milliseconds. |
long |
size()
|
void |
textReplace(java.util.List<java.lang.String> replacements)
Does a simple text replacement on the entire file. |
void |
textReplace(java.lang.String... replacements)
Does a simple text replacement on the entire file. |
VfsFile |
withExtension(java.lang.String extension)
|
void |
writeBytes(byte[] bytes)
Writes the given bytes to the file. |
void |
writeText(java.lang.String text)
Write the given String text to the file. |
| Methods inherited from interface com.partnersoft.io.vfs.VfsNode |
|---|
exists, getAbsolutePath, getBaseName, getDirectory, getExtension, getName, getPath, getUri, getUrl, getVfs, isBackup, isHidden, make, toFile |
| Method Detail |
|---|
long size()
throws java.io.IOException
java.io.IOExceptionVfsFile withExtension(java.lang.String extension)
void remove()
throws java.io.IOException
java.io.IOException
VfsFile renameTo(java.lang.String name)
throws java.io.IOException
java.io.IOException
VfsFile moveTo(Path newPath)
throws java.io.IOException
java.io.IOException
VfsFile copyTo(Path newPath)
throws java.io.IOException
java.io.IOException
VfsFile copyTo(VfsFile destination)
throws java.io.IOException
java.io.IOException
VfsFile moveTo(VfsFile destination)
throws java.io.IOException
java.io.IOException
void writeText(java.lang.String text)
throws java.io.IOException
text - text to write to the file.
java.io.IOException - if unable to write
java.lang.String readText()
throws java.io.IOException
java.io.IOException - if unable to read
java.lang.String readTextRange(long start,
long end)
throws java.io.IOException
java.io.IOException
java.util.List<java.lang.String> readTextAsLines()
throws java.io.IOException
java.io.IOException - if unable to read
void appendText(java.lang.String text)
throws java.io.IOException
text - text to append
java.io.IOException - if unable to append
void writeBytes(byte[] bytes)
throws java.io.IOException
bytes - byte contents to write
java.io.IOException - if unable to write
void appendBytes(byte[] bytes)
throws java.io.IOException
bytes - bytes to append to file
java.io.IOException - if unable to append
byte[] readBytes()
throws java.io.IOException
java.io.IOException - if unable to read
void textReplace(java.util.List<java.lang.String> replacements)
throws java.io.IOException
replacements - list of strings, in alternating original1, replacement1, original2, replacement2, etc. order
java.io.IOException
void textReplace(java.lang.String... replacements)
throws java.io.IOException
replacements - array or vararg list of strings, in alternating original1, replacement1, original2, replacement2, etc. order
java.io.IOException
void regexReplace(java.util.List<java.lang.String> replacements)
throws java.io.IOException
replacements - list of strings, in alternating regex1, replacement1, regex2, replacement2, etc. order
java.io.IOException
void regexReplace(java.lang.String... replacements)
throws java.io.IOException
replacements - array or vararg list of strings, in alternating regex1, replacement1, regex2, replacement2, etc. order
java.io.IOException
java.io.InputStream createInputStream()
throws java.io.IOException
InputStream.close() when you are done with it. Note that
this stream is NOT buffered. This is usually a bad thing, unless you are
doing your own buffering or doing a single bulk read. So, don't use this
method unless you know what you're doing - use
createBufferedInputStream() instead.
java.io.IOException - if the read fails
java.io.BufferedInputStream createBufferedInputStream()
throws java.io.IOException
OutputStream.close() when you are done with it. This
stream is buffered. This is usually a good thing. So, generally use this
method instead of createInputStream() unless you know what
you're doing.
java.io.IOException - if the read fails
java.io.OutputStream createOutputStream()
throws java.io.IOException
OutputStream.close()).
Note that this stream is NOT buffered. This is usually a bad thing,
unless you are doing your own buffering or doing a bulk write. So, don't
use this method unless you know what you're doing - use
createBufferedOutputStream() instead.
java.io.IOException
java.io.BufferedOutputStream createBufferedOutputStream()
throws java.io.IOException
OutputStream.close()).
This stream is buffered, which is usually a good thing. You should
generally use this instead of createOutputStream() unless you
know what you're doing.
java.io.IOException
java.io.OutputStream createAppendingOutputStream()
throws java.io.IOException
OutputStream.close()).
Note that this stream is NOT buffered. This is usually a bad thing,
unless you are doing your own buffering or doing a bulk write. So, don't
use this method unless you know what you're doing - use
createAppendingBufferedOutputStream() instead.
java.io.IOException
java.io.BufferedOutputStream createAppendingBufferedOutputStream()
throws java.io.IOException
OutputStream.close()).
This stream is buffered, which is usually a good thing. You should
generally use this instead of createAppendingOutputStream()
unless you know what you're doing.
java.io.IOException
java.io.Reader createReader()
throws java.io.IOException
Reader.close()
when you are done with it. Note that this reader is NOT buffered. This is
usually a bad thing, unless you are doing your own buffering or doing a
single bulk read. So, don't use this method unless you know what you're
doing - use createBufferedReader() instead.
java.io.IOException - if the read fails
java.io.BufferedReader createBufferedReader()
throws java.io.IOException
Reader.close() when you are done with it. This reader is
buffered. This is usually a good thing. So, generally use this method
instead of createReader() unless you know what you're doing.
java.io.IOException - if the read fails
java.io.Writer createWriter()
throws java.io.IOException
Writer.close()). Note that
this writer is NOT buffered. This is usually a bad thing, unless you are
doing your own buffering or doing a bulk write. So, don't use this method
unless you know what you're doing - use createBufferedWriter()
instead.
java.io.IOException
java.io.BufferedWriter createBufferedWriter()
throws java.io.IOException
Writer.close()). This
writer is buffered, which is usually a good thing. You should generally
use this instead of createWriter() unless you know what you're
doing.
java.io.IOException
java.io.Writer createAppendingWriter()
throws java.io.IOException
Writer.close()).
Note that this writer is NOT buffered. This is usually a bad thing,
unless you are doing your own buffering or doing a bulk write. So, don't
use this method unless you know what you're doing - use
createAppendingBufferedWriter() instead.
java.io.IOException
java.io.BufferedWriter createAppendingBufferedWriter()
throws java.io.IOException
createAppendingWriter() unless you
know what you're doing.
java.io.IOException
VfsRandomAccess createRandomAccess()
throws java.io.IOException
java.io.IOException - if file can't be accessed
DateAndTime getLastModified()
throws java.io.IOException
new DateAndTime(getLastModifiedMillis()).
java.io.IOException
void setLastModified(DateAndTime newLast)
throws java.io.IOException
setLastModifiedMillis(newLast.getMillis()).
java.io.IOException
long getLastModifiedMillis()
throws java.io.IOException
getLastModified().getMillis().
java.io.IOException
void setLastModifiedMillis(long millis)
throws java.io.IOException
setLastModified(new DateAndTime(millis)).
java.io.IOException
long checksum()
throws java.io.IOException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||