org.apache.catalina.webresources

## Class FileResource

- java.lang.Object
- - org.apache.catalina.webresources.AbstractResource
  - - org.apache.catalina.webresources.FileResource

- All Implemented Interfaces:
    WebResource

      public class FileResource
      extends AbstractResource

  Represents a single resource (file or directory) that is located on a file system.

- - ### Field Summary

    - ### Fields inherited from class org.apache.catalina.webresources.AbstractResource

      `sm`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileResource(WebResourceRoot root, String webAppPath, File resource, boolean readOnly, Manifest manifest)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canRead()`
    `boolean` | `delete()`
    `protected InputStream` | `doGetInputStream()`
    `boolean` | `exists()`
    `String` | `getCanonicalPath()`
    `Certificate[]` | `getCertificates()`
    `URL` | `getCodeBase()`
    `byte[]` | `getContent()`
    `long` | `getContentLength()`
    `long` | `getCreation()`
    `long` | `getLastModified()`
    `protected Log` | `getLog()`
    `Manifest` | `getManifest()`
    `String` | `getName()`
    `URL` | `getURL()`
    `boolean` | `isDirectory()`
    `boolean` | `isFile()`
    `boolean` | `isVirtual()` Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additional `WebResourceSet`.

    - ### Methods inherited from class org.apache.catalina.webresources.AbstractResource

      `getETag, getInputStream, getLastModifiedHttp, getMimeType, getWebappPath, getWebResourceRoot, setMimeType`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileResource

          public FileResource(WebResourceRoot root,
                      String webAppPath,
                      File resource,
                      boolean readOnly,
                      Manifest manifest)

  - ### Method Detail

    - #### getLastModified

          public long getLastModified()

      Returns:
        `File.lastModified()`.

    - #### exists

          public boolean exists()

      Returns:
        `File.exists()`.

    - #### isVirtual

          public boolean isVirtual()

      Description copied from interface: `WebResource`
      Indicates if this resource is required for applications to correctly scan the file structure but that does not exist in either the main or any additional `WebResourceSet`. For example, if an external directory is mapped to /WEB-INF/lib in an otherwise empty web application, /WEB-INF will be represented as a virtual resource.
      Returns:
        `true` for a virtual resource

    - #### isDirectory

          public boolean isDirectory()

      Returns:
        `File.isDirectory()`.

    - #### isFile

          public boolean isFile()

      Returns:
        `File.isFile()`.

    - #### delete

          public boolean delete()

      Returns:
        `File.delete()`.

    - #### getName

          public String getName()

      Returns:
        `File.getName()`.

    - #### getContentLength

          public long getContentLength()

      Returns:
        `File.length()`.

    - #### getCanonicalPath

          public String getCanonicalPath()

      Returns:
        `File.getCanonicalPath()`.

    - #### canRead

          public boolean canRead()

      Returns:
        `File.canRead()`.

    - #### doGetInputStream

          protected InputStream doGetInputStream()

      Specified by:
        `doGetInputStream` in class `AbstractResource`

    - #### getContent

          public final byte[] getContent()

      Returns:
        the cached binary content of this resource.

    - #### getCreation

          public long getCreation()

      Returns:
        The time the file was created. If not available, the result of `WebResource.getLastModified()` will be returned.

    - #### getURL

          public URL getURL()

      Returns:
        a URL to access the resource or `null` if no such URL is available or if the resource does not exist.

    - #### getCodeBase

          public URL getCodeBase()

      Returns:
        the code base for this resource that will be used when looking up the assigned permissions for the code base in the security policy file when running under a security manager.

    - #### getCertificates

          public Certificate[] getCertificates()

      Returns:
        the certificates that were used to sign this resource to verify it or @null if none.
      See Also:
        `JarEntry.getCertificates()`

    - #### getManifest

          public Manifest getManifest()

      Returns:
        the manifest associated with this resource or @null if none.
      See Also:
        `JarFile.getManifest()`

    - #### getLog

          protected Log getLog()

      Specified by:
        `getLog` in class `AbstractResource`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.