|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
com.devexperts.io.URLInputStream
public class URLInputStream
Convenient class that opens specified URL for reading. It supports all URL formats supported by Java and also understands file names using both local and absolute paths. It properly configures outgoing connections and releases all resources when closed.
To open HTTP resources use standard HTTP URL syntax:
To open FTP resources use standard FTP URL syntax:
To open file use either local file name or standard file URL syntax:
Field Summary | |
---|---|
protected URLConnection |
connection
|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
URLInputStream(String url)
Creates a URLInputStream for specified URL. |
Method Summary | |
---|---|
void |
close()
|
protected void |
finalize()
|
long |
getLastModified()
This method returns last modification time from this URLInputStream . |
static long |
getLastModified(String url)
Returns last modification time for a specified URL. |
static byte[] |
readURL(String url)
Reads content for specified URL and returns it as a byte array. |
Methods inherited from class java.io.FilterInputStream |
---|
available, mark, markSupported, read, read, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final URLConnection connection
Constructor Detail |
---|
public URLInputStream(String url) throws IOException
url
- the URL to open
IOException
- if an I/O error occursMethod Detail |
---|
public static byte[] readURL(String url) throws IOException
url
- the URL to read
IOException
- if an I/O error occurspublic static long getLastModified(String url) throws IOException
IOException
- if there is some problem retrieving last modification time or it is not known.public long getLastModified()
URLInputStream
.
Returns 0 when last modification time is not known.
public void close() throws IOException
close
in interface Closeable
close
in class FilterInputStream
IOException
protected void finalize() throws IOException
finalize
in class Object
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |