public class FileRepresentation extends Representation
Disposition.setType(String) with a
Disposition.TYPE_ATTACHMENT value.UNKNOWN_SIZE| Constructor and Description |
|---|
FileRepresentation(File file,
MediaType mediaType)
Constructor that does not set an expiration date for
file |
FileRepresentation(File file,
MediaType mediaType,
int timeToLive)
Constructor.
|
FileRepresentation(String path,
MediaType mediaType)
Constructor that does not set an expiration date for
path |
FileRepresentation(String path,
MediaType mediaType,
int timeToLive)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
FileChannel |
getChannel()
Deprecated.
|
File |
getFile()
Returns the file handle.
|
Reader |
getReader()
Returns a characters reader with the representation's content.
|
long |
getSize()
Returns the total size in bytes if known, UNKNOWN_SIZE (-1) otherwise.
|
FileInputStream |
getStream()
Returns a stream with the representation's content.
|
String |
getText()
Note that this method relies on
getStream(). |
boolean |
isAutoDeleting()
Indicates if this file should be automatically deleted on release of the
representation.
|
void |
release()
Releases the file handle.
|
void |
setAutoDeleting(boolean autoDeleting)
Indicates if this file should be automatically deleted on release of the
representation.
|
void |
setFile(File file)
Sets the file handle.
|
void |
write(OutputStream outputStream)
Writes the representation to a byte stream.
|
void |
write(WritableByteChannel writableChannel)
Deprecated.
|
void |
write(Writer writer)
Writes the representation to a characters writer.
|
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransientgetModificationDate, getTag, setModificationDate, setTagcreateClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toStringpublic FileRepresentation(File file, MediaType mediaType)
filefile - The represented file.mediaType - The representation's media type.FileRepresentation(File, MediaType, int)public FileRepresentation(File file, MediaType mediaType, int timeToLive)
file - The represented file.mediaType - The representation's media type.timeToLive - The time to live before it expires (in seconds).public FileRepresentation(String path, MediaType mediaType)
pathpath - The path name or file URI of the represented file (either in
system format or in 'file:///' format).mediaType - The representation's media type.FileRepresentation(String, MediaType, int)public FileRepresentation(String path, MediaType mediaType, int timeToLive)
path - The path name or file URI of the represented file (either
in system format or in 'file:///' format).mediaType - The representation's media type.timeToLive - The time to live before it expires (in seconds).File(String)@Deprecated public FileChannel getChannel() throws IOException
getChannel in class RepresentationIOExceptionpublic File getFile()
public Reader getReader() throws IOException
RepresentationgetReader in class RepresentationIOExceptionpublic long getSize()
RepresentationRepresentation.getAvailableSize() method.getSize in class RepresentationRepresentation.isEmpty()public FileInputStream getStream() throws IOException
RepresentationgetStream in class RepresentationIOExceptionpublic String getText() throws IOException
getStream(). This stream is closed
once fully read.getText in class RepresentationIOExceptionpublic boolean isAutoDeleting()
public void release()
release in class Representationpublic void setAutoDeleting(boolean autoDeleting)
autoDeleting - True if this file should be automatically deleted on
release of the representation.public void setFile(File file)
file - The file handle.public void write(OutputStream outputStream) throws IOException
RepresentationOutputStream after writing to it as this will be handled by the
Restlet connectors automatically.write in class RepresentationoutputStream - The output stream.IOException@Deprecated public void write(WritableByteChannel writableChannel) throws IOException
write in class RepresentationwritableChannel - A writable byte channel.IOExceptionpublic void write(Writer writer) throws IOException
RepresentationWriter after writing to it as this will be handled by
the Restlet connectors automatically.write in class Representationwriter - The characters writer.IOExceptionCopyright © 2005–2025. All rights reserved.