4.1 Resource

Resource

1. Resource API

1
2
3
public interface InputStreamSource {  
InputStream getInputStream() throws IOException;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
public interface Resource extends InputStreamSource {  
boolean exists();
boolean isReadable();
boolean isOpen();
URL getURL() throws IOException;
URI getURI() throws IOException;
File getFile() throws IOException;
long contentLength() throws IOException;
long lastModified() throws IOException;
Resource createRelative(String relativePath) throws IOException;
String getFilename();
String getDescription();
}
  • InputStreamSource:

    • getInputStream: Return new java.io.InputStream which needs close after used.
  • Resource extends InputStreamSource:

    • exists: Resource exists?

    • isReadable: Resource readable?

    • isOpen: Resource open?

    • getURL: java.util.URL.

    • getURI: java.util.URI.

    URIs identify and URLs locate; however, locators are also identifiers, so every URL is also a URI, but there are URIs which are not URLs.

    • getFile: java.io.File.

    • contentLength: Resource length.

    • lastModified_: Modified date.

    • createRelateive: create file in Resource.

    • getFilename: ONLY return file path.

    • getDescription return full file path.