|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.entityfs.util.base.AbstractWritableFile org.entityfs.util.FileWritableFile
public class FileWritableFile
This is a WritableFile
that encapsulates a File
The locking methods return a NoObjectDummyLock
.
FileReadableFile
Constructor Summary | |
---|---|
FileWritableFile(File f)
|
Method Summary | |
---|---|
boolean |
equals(Object o)
|
File |
getFile()
Get the encapsulated File object. |
int |
hashCode()
|
WritableByteChannel |
openChannelForAppend()
This method opens a byte channel on the OutputStream returned
from openForAppend . |
WritableByteChannel |
openChannelForWrite()
This method opens a byte channel on the OutputStream returned
from openForWrite . |
OutputStream |
openForAppend()
Open the file for appending. |
OutputStream |
openForWrite()
Opens the file for writing. |
String |
toString()
|
Methods inherited from class org.entityfs.util.base.AbstractWritableFile |
---|
getWriteLock, isWriteLockedByCurrentThread, lockForWriting |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FileWritableFile(File f)
Method Detail |
---|
public File getFile()
File
object.
File
object.public WritableByteChannel openChannelForAppend() throws WrappedIOException
AbstractWritableFile
OutputStream
returned
from openForAppend
.
openChannelForAppend
in interface WritableFile
openChannelForAppend
in class AbstractWritableFile
WritableByteChannel
. The channel must be closed
by the caller. The returned channel may be a
GatheringByteChannel
, but that is not required.
WrappedIOException
public WritableByteChannel openChannelForWrite() throws WrappedIOException
AbstractWritableFile
OutputStream
returned
from openForWrite
.
openChannelForWrite
in interface WritableFile
openChannelForWrite
in class AbstractWritableFile
WritableByteChannel
. The channel must be closed
by the caller. The returned channel may be a
GatheringByteChannel
, but that is not required.
WrappedIOException
WritableFile.openForWrite()
,
WritableFile.openChannelForAppend()
public OutputStream openForAppend() throws WrappedIOException
WritableFile
WritableFile.openForWrite()
to delete the previous contents before
writing. This requires that the file supports the
FCAppendable
capability (and/or that the
file system supports the FSCAppendableFiles
capability.
The caller is responsible for closing the stream.
When two appending output streams are open on the same file, one stream will not overwrite contents written by the other stream. Compare this with the behavior of one writing and one appending stream.
Although a write lock on the file is required for the execution thread
opening the stream, the stream itself is not protected from access by
other threads. It can be protected by wrapping it in a
LockAwareWritableByteChannel
.
OutputStream
to write to. The stream must be closed by
the caller.
WrappedIOException
WritableFile.openForWrite()
,
WritableFile.openChannelForAppend()
public OutputStream openForWrite() throws WriteLockRequiredException, AccessDeniedException, ReadOnlyException
WritableFile
WritableFile.openForAppend()
to append to the file.
The caller is responsible for closing the stream.
When two output streams, one writing and one appending are open on the same file, the stream opened for write will ignore the contents written by the other stream and the content written by the other stream will be overwritten. When two or more appending streams are opened on a file, a stream will not overwrite the content written by the other streams.
Although a write lock on the file is required for the execution thread
opening the stream, the stream itself is not protected from access by
other threads. It can be protected by wrapping it in a
LockAwareOutputStream
.
OutputStream
to write to. The stream must be closed by
the caller.
WriteLockRequiredException
- If the client does not have a write
lock for the file.
AccessDeniedException
- If the client does not have write access to
the file.
ReadOnlyException
- If the file system is read-only.WritableFile.openForAppend()
,
WritableFile.openChannelForWrite()
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |