Package org.apache.wicket.util.resource
Class FileResourceStream
- java.lang.Object
-
- org.apache.wicket.util.resource.AbstractResourceStream
-
- org.apache.wicket.util.resource.FileResourceStream
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IFixedLocationResourceStream
,IResourceStream
,IModifiable
public class FileResourceStream extends AbstractResourceStream implements IFixedLocationResourceStream
A FileResourceStream is an IResource implementation for files.- Author:
- Jonathan Locke
- See Also:
IResourceStream
,IModifiable
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FileResourceStream(File file)
Constructor.FileResourceStream(File file)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this resource.String
getContentType()
Gets the mime type of this resourceFile
getFile()
InputStream
getInputStream()
Gets the resource stream.Instant
lastModifiedTime()
Gets the last time this modifiable thing changed.Bytes
length()
Gets the size of this resourceString
locationAsString()
String
toString()
-
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
-
-
-
-
Constructor Detail
-
FileResourceStream
public FileResourceStream(File file)
Constructor.- Parameters:
file
-File
containing resource
-
FileResourceStream
public FileResourceStream(File file)
Constructor.- Parameters:
file
-File
containing resource
-
-
Method Detail
-
close
public void close() throws IOException
Closes this resource.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceIResourceStream
- Throws:
IOException
-
getContentType
public String getContentType()
Description copied from interface:IResourceStream
Gets the mime type of this resource- Specified by:
getContentType
in interfaceIResourceStream
- Overrides:
getContentType
in classAbstractResourceStream
- Returns:
- The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestHandler handle the Content-Type automatically
-
getInputStream
public InputStream getInputStream() throws ResourceStreamNotFoundException
Description copied from interface:IResourceStream
Gets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.- Specified by:
getInputStream
in interfaceIResourceStream
- Returns:
- A readable input stream for this resource. The same input stream is returned until FileResourceStream.close() is invoked.
- Throws:
ResourceStreamNotFoundException
- See Also:
IResourceStream.close()
-
lastModifiedTime
public Instant lastModifiedTime()
Description copied from interface:IModifiable
Gets the last time this modifiable thing changed.- Specified by:
lastModifiedTime
in interfaceIModifiable
- Overrides:
lastModifiedTime
in classAbstractResourceStream
- Returns:
- The last time this resource was modified
- See Also:
IModifiable.lastModifiedTime()
-
length
public Bytes length()
Description copied from interface:IResourceStream
Gets the size of this resource- Specified by:
length
in interfaceIResourceStream
- Overrides:
length
in classAbstractResourceStream
- Returns:
- The size of this resource in the number of bytes, or
null
if unknown
-
locationAsString
public String locationAsString()
- Specified by:
locationAsString
in interfaceIFixedLocationResourceStream
- Returns:
- The fixed location as a string, e.g. the file name or the URL. Return null to avoid caching the markup.
-
-