|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.resource.Variant
org.restlet.resource.Representation
org.restlet.resource.FileRepresentation
public class FileRepresentation
Representation based on a file.
Field Summary |
---|
Fields inherited from class org.restlet.resource.Representation |
---|
UNKNOWN_SIZE |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
FileChannel |
getChannel()
Returns a readable byte channel. |
File |
getFile()
Returns the file handle. |
Reader |
getReader()
Returns a characters reader with the representation's content. |
long |
getSize()
Returns the size in bytes if known, UNKNOWN_SIZE (-1) otherwise. |
FileInputStream |
getStream()
Returns a stream with the representation's content. |
String |
getText()
Converts the representation to a string value. |
void |
release()
Releases the file handle. |
void |
setFile(File file)
Sets the file handle. |
void |
write(OutputStream outputStream)
Writes the representation to a byte stream. |
void |
write(WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
void |
write(Writer writer)
Writes the representation to a characters writer. |
Methods inherited from class org.restlet.resource.Representation |
---|
checkDigest, checkDigest, computeDigest, createEmpty, exhaust, getAvailableSize, getDigest, getDownloadName, getExpirationDate, getModificationDate, getRange, getTag, isAvailable, isDownloadable, isTransient, setAvailable, setDigest, setDownloadable, setDownloadName, setExpirationDate, setModificationDate, setRange, setSize, setTag, setTransient |
Methods inherited from class org.restlet.resource.Variant |
---|
getCharacterSet, getEncodings, getIdentifier, getLanguages, getMediaType, setCharacterSet, setEncodings, setIdentifier, setIdentifier, setLanguages, setMediaType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileRepresentation(File file, MediaType mediaType)
file
file
- 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)
path
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.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.File(String)
Method Detail |
---|
public FileChannel getChannel() throws IOException
getChannel
in class Representation
IOException
public File getFile()
public Reader getReader() throws IOException
Representation
getReader
in class Representation
IOException
public long getSize()
Representation
getSize
in class Representation
public FileInputStream getStream() throws IOException
Representation
getStream
in class Representation
IOException
public String getText() throws IOException
Representation
getText
in class Representation
IOException
public void release()
release
in class Representation
public void setFile(File file)
file
- The file handle.public void write(OutputStream outputStream) throws IOException
Representation
write
in class Representation
outputStream
- The output stream.
IOException
public void write(WritableByteChannel writableChannel) throws IOException
write
in class Representation
writableChannel
- A writable byte channel.
IOException
public void write(Writer writer) throws IOException
Representation
write
in class Representation
writer
- The characters writer.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |