Example:
URLDownload dl = new URLDownload(URL);
String content = dl.asString(ENCODING);
dl.toFile(Path); // available in FILE
String contentType = dl.getMimeType();
Almost each call to a public method creates a new HTTP connection (except for asString,
which uses an already opened connection). Nothing is cached.
| Modifier and Type | Field and Description |
|---|---|
| private Duration | |
| private static final Duration | |
| private static final Logger | |
| private final Map | |
| private String | |
| private final URL | |
| public static final String |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public ProgressInputStream | |
| public String | |
| public String | |
| public static String | Returns: the downloaded stringan existing connection existingConnection)Downloads the web resource to a String from an existing connection. |
| public static String | Returns: the downloaded stringthe desired String encoding encoding, URLConnection an existing connection connection)Downloads the web resource to a String. |
| public static void | bypassSSLVerification()
Deprecated
Older java VMs does not automatically trust the zbMATH certificate. |
| public boolean | Returns: the status code of the responseCheck the connection by using the HEAD request. |
| private static void | |
| public Duration | |
| public List | |
| public String | |
| public URL | |
| public boolean | |
| public boolean | |
| public URLConnection | Returns: an open connectionOpen a connection to this object's URL (with specified settings). |
| public void | |
| public void | |
| public static void | setSSLVerification(SSLSocketFactory
trust manager socketFactory, HostnameVerifier host verifier verifier)
|
| public void | |
| public String | |
| public Path | Returns: the path of the temporary file.Downloads the web resource to a temporary file. |
| connectTimeout | back to summary |
|---|---|
| private Duration connectTimeout | |
| DEFAULT_CONNECT_TIMEOUT | back to summary |
|---|---|
| private static final Duration DEFAULT_CONNECT_TIMEOUT | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| parameters | back to summary |
|---|---|
| private final Map<String, String> parameters | |
| postData | back to summary |
|---|---|
| private String postData | |
| source | back to summary |
|---|---|
| private final URL source | |
| USER_AGENT | back to summary |
|---|---|
| public static final String USER_AGENT | |
| URLDownload | back to summary |
|---|---|
public URLDownload(String source) throws MalformedURLException
| |
| URLDownload | back to summary |
|---|---|
public URLDownload(URL source)
| |
| addHeader | back to summary |
|---|---|
| public void addHeader(String key, String value) | |
| asInputStream | back to summary |
|---|---|
| public ProgressInputStream asInputStream() throws IOException Takes the web resource as the source for a monitored input stream. | |
| asString | back to summary |
|---|---|
| public String asString() throws IOException Downloads the web resource to a String. Uses UTF-8 as encoding.
| |
| asString | back to summary |
|---|---|
| public String asString(Charset encoding) throws IOException Downloads the web resource to a String. | |
| asString | back to summary |
|---|---|
| public static String asString(URLConnection existingConnection) throws IOException Downloads the web resource to a String from an existing connection. Uses UTF-8 as encoding.
| |
| asString | back to summary |
|---|---|
| public static String asString(Charset encoding, URLConnection connection) throws IOException Downloads the web resource to a String.
| |
| bypassSSLVerification | back to summary |
|---|---|
| public static void bypassSSLVerification()
Deprecated
Older java VMs does not automatically trust the zbMATH certificate. In this case the following exception is thrown: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target JM > 8u101 may trust the certificate by default according to http://stackoverflow.com/a/34111150/873661 We will fix this issue by accepting all (!) certificates. This is ugly; but as JabRef does not rely on security-relevant information this is kind of OK (no, actually it is not...). Taken from http://stackoverflow.com/a/6055903/873661 and https://stackoverflow.com/a/19542614/873661
| |
| canBeReached | back to summary |
|---|---|
| public boolean canBeReached() throws kong.unirest.core.UnirestException Check the connection by using the HEAD request. UnirestException can be thrown for invalid request.
| |
| copy | back to summary |
|---|---|
| private static void copy(InputStream in, Writer out, Charset encoding) throws IOException | |
| getConnectTimeout | back to summary |
|---|---|
| public Duration getConnectTimeout() | |
| getCookieFromUrl | back to summary |
|---|---|
| public List | |
| getMimeType | back to summary |
|---|---|
| public String getMimeType() | |
| getSource | back to summary |
|---|---|
| public URL getSource() | |
| isMimeType | back to summary |
|---|---|
| public boolean isMimeType(String type) | |
| isPdf | back to summary |
|---|---|
| public boolean isPdf() | |
| openConnection | back to summary |
|---|---|
| public URLConnection openConnection() throws IOException Open a connection to this object's URL (with specified settings). If accessing an HTTP URL, don't forget to close the resulting connection after usage.
| |
| setConnectTimeout | back to summary |
|---|---|
| public void setConnectTimeout(Duration connectTimeout) | |
| setPostData | back to summary |
|---|---|
| public void setPostData(String postData) | |
| setSSLVerification | back to summary |
|---|---|
public static void setSSLVerification(SSLSocketFactory socketFactory, HostnameVerifier verifier)
| |
| toFile | back to summary |
|---|---|
| public void toFile(Path destination) throws IOException Downloads the web resource to a file.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| toTemporaryFile | back to summary |
|---|---|
| public Path toTemporaryFile() throws IOException Downloads the web resource to a temporary file.
| |