public interface FileContents
FileContents
objects encapsulate the name
and contents of a file. An implementation of this class is
used by the FileOpenService
,
FileSaveService
, and
PersistenceService
.
The FileContents
implementation returned by
PersistenceService.get(java.net.URL)
, FileOpenService
,
and FileSaveService
should never truncate a file
if the maximum file length is set to be less that the current
file length.
FileOpenService
,
FileSaveService
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Returns whether the file can be read.
|
boolean |
canWrite()
Returns whether the file can be written to.
|
java.io.InputStream |
getInputStream()
Gets an
InputStream from the file. |
long |
getLength()
Gets the length of the file.
|
long |
getMaxLength()
Gets the maximum file length for the file,
as set by the creator of this object.
|
java.lang.String |
getName()
Gets the file name as a
String . |
java.io.OutputStream |
getOutputStream(boolean overwrite)
Gets an
OutputStream to the file. |
JNLPRandomAccessFile |
getRandomAccessFile(java.lang.String mode)
Returns a
JNLPRandomAccessFile representing a
random access interface to the file's contents. |
long |
setMaxLength(long maxlength)
Sets the maximum file length for the file.
|
java.lang.String getName() throws java.io.IOException
String
.java.io.IOException
- if an I/O exception occurs.java.io.InputStream getInputStream() throws java.io.IOException
InputStream
from the file.java.io.IOException
- if an I/O exception occurs.java.io.OutputStream getOutputStream(boolean overwrite) throws java.io.IOException
OutputStream
to the file. A JNLP
client may implement this interface to return an OutputStream
subclass which restricts the amount of data that can be
written to the stream.java.io.IOException
- if an I/O exception occurs.long getLength() throws java.io.IOException
java.io.IOException
- if an I/O exception occurs.boolean canRead() throws java.io.IOException
java.io.IOException
- if an I/O exception occurs.boolean canWrite() throws java.io.IOException
java.io.IOException
- if an I/O exception occurs.JNLPRandomAccessFile getRandomAccessFile(java.lang.String mode) throws java.io.IOException
JNLPRandomAccessFile
representing a
random access interface to the file's contents.
The mode argument must either be equal to "r" or "rw",
indicating the file is to be opened for input only or for both
input and output, respectively. An IllegalArgumentException
will be thrown if the mode is not equal to "r" or "rw".mode
- the access mode.java.io.IOException
- if an I/O exception occurs.long getMaxLength() throws java.io.IOException
java.io.IOException
- if an I/O exception occurs.long setMaxLength(long maxlength) throws java.io.IOException
maxlength
- the requested new maximum file length.java.io.IOException
- if an I/O exception occurs.Copyright © 1998, 2016, Oracle and/or its affiliates. All rights reserved.