|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.openstreetmap.josm.io.MirroredInputStream
public class MirroredInputStream
Mirrors a file to a local file.
The file mirrored is only downloaded if it has been more than 7 days since last download
Field Summary | |
---|---|
static long |
DEFAULT_MAXTIME
|
(package private) java.io.File |
file
|
(package private) java.io.InputStream |
fs
|
Constructor Summary | |
---|---|
MirroredInputStream(java.lang.String name)
|
|
MirroredInputStream(java.lang.String name,
long maxTime)
|
|
MirroredInputStream(java.lang.String name,
java.lang.String destDir)
|
|
MirroredInputStream(java.lang.String name,
java.lang.String destDir,
long maxTime)
Get an inputstream from a given filename, url or internal resource. |
Method Summary | |
---|---|
int |
available()
|
private java.io.File |
checkLocal(java.net.URL url,
java.lang.String destDir,
long maxTime)
|
static void |
cleanup(java.lang.String name)
|
static void |
cleanup(java.lang.String name,
java.lang.String destDir)
|
void |
close()
|
protected java.net.HttpURLConnection |
connectFollowingRedirect(java.net.URL downloadUrl)
Opens a connection for downloading a resource. |
java.io.File |
getFile()
|
private static java.lang.String |
getPrefKey(java.net.URL url,
java.lang.String destDir)
get preference key to store the location and age of the cached file. |
java.io.InputStream |
getZipEntry(java.lang.String extension,
java.lang.String namepart)
Replies an input stream for a file in a ZIP-file. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
long |
skip(long n)
|
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.io.InputStream fs
java.io.File file
public static final long DEFAULT_MAXTIME
Constructor Detail |
---|
public MirroredInputStream(java.lang.String name) throws java.io.IOException
java.io.IOException
public MirroredInputStream(java.lang.String name, long maxTime) throws java.io.IOException
java.io.IOException
public MirroredInputStream(java.lang.String name, java.lang.String destDir) throws java.io.IOException
java.io.IOException
public MirroredInputStream(java.lang.String name, java.lang.String destDir, long maxTime) throws java.io.IOException
name
- can be
- relative or absolute file name
- file:///SOME/FILE the same as above
- resource://SOME/FILE file from the classpath (usually in the current *.jar)
- http://... a url. It will be cached on disk.destDir
- the destination directory for the cache file. only applies for urls.maxTime
- the maximum age of the cache file (in seconds)
java.io.IOException
- when the resource with the given name could not be retrievedMethod Detail |
---|
public java.io.InputStream getZipEntry(java.lang.String extension, java.lang.String namepart)
extension
. If more
than one files have this extension, the last file whose name includes namepart
is opened.
extension
- the extension of the file we're looking fornamepart
- the name part
public java.io.File getFile()
public static void cleanup(java.lang.String name)
public static void cleanup(java.lang.String name, java.lang.String destDir)
private static java.lang.String getPrefKey(java.net.URL url, java.lang.String destDir)
private java.io.File checkLocal(java.net.URL url, java.lang.String destDir, long maxTime) throws java.io.IOException
java.io.IOException
protected java.net.HttpURLConnection connectFollowingRedirect(java.net.URL downloadUrl) throws java.net.MalformedURLException, java.io.IOException
Manually follows redirects because
HttpURLConnection.setFollowRedirects(boolean)
fails if the redirect
is going from a http to a https URL, see bug report.
This can causes problems when downloading from certain GitHub URLs.
java.net.MalformedURLException
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |