|
||||||||||
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(java.io.File file,
MediaType mediaType)
Constructor that does not set an expiration date for file |
|
FileRepresentation(java.io.File file,
MediaType mediaType,
int timeToLive)
Constructor. |
|
FileRepresentation(java.lang.String path,
MediaType mediaType)
Constructor that does not set an expiration date for path |
|
FileRepresentation(java.lang.String path,
MediaType mediaType,
int timeToLive)
Constructor. |
Method Summary | |
---|---|
java.nio.channels.FileChannel |
getChannel()
Returns a readable byte channel. |
java.io.File |
getFile()
Returns the file handle. |
java.io.Reader |
getReader()
Returns a characters reader with the representation's content. |
long |
getSize()
Returns the size in bytes if known, UNKNOWN_SIZE (-1) otherwise. |
java.io.FileInputStream |
getStream()
Returns a stream with the representation's content. |
java.lang.String |
getText()
Converts the representation to a string value. |
void |
release()
Releases the file handle. |
void |
setFile(java.io.File file)
Sets the file handle. |
void |
write(java.io.OutputStream outputStream)
Writes the representation to a byte stream. |
void |
write(java.nio.channels.WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
void |
write(java.io.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(java.io.File file, MediaType mediaType)
file
file
- The represented file.mediaType
- The representation's media type.FileRepresentation(File, MediaType, int)
public FileRepresentation(java.io.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(java.lang.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(java.lang.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 java.nio.channels.FileChannel getChannel() throws java.io.IOException
getChannel
in class Representation
java.io.IOException
public java.io.File getFile()
public java.io.Reader getReader() throws java.io.IOException
Representation
getReader
in class Representation
java.io.IOException
public long getSize()
Representation
getSize
in class Representation
public java.io.FileInputStream getStream() throws java.io.IOException
Representation
getStream
in class Representation
java.io.IOException
public java.lang.String getText() throws java.io.IOException
Representation
getText
in class Representation
java.io.IOException
public void release()
release
in class Representation
public void setFile(java.io.File file)
file
- The file handle.public void write(java.io.OutputStream outputStream) throws java.io.IOException
Representation
write
in class Representation
outputStream
- The output stream.
java.io.IOException
public void write(java.nio.channels.WritableByteChannel writableChannel) throws java.io.IOException
write
in class Representation
writableChannel
- A writable byte channel.
java.io.IOException
public void write(java.io.Writer writer) throws java.io.IOException
Representation
write
in class Representation
writer
- The characters writer.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |