public class URLConnectionTools extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CONNECTION_TIMEOUT
The default connection timeout in ms - 15 seconds
|
Constructor and Description |
---|
URLConnectionTools() |
Modifier and Type | Method and Description |
---|---|
static InputStream |
doPOST(URL url,
String data)
Do a POST to a URL and return the response stream for further processing elsewhere.
|
static InputStream |
doPOST(URL url,
String data,
int timeout)
Do a POST to a URL and return the response stream for further processing elsewhere.
|
static InputStream |
getInputStream(URL url)
Connect to a URL and return result as an InputStream.
|
static InputStream |
getInputStream(URL url,
boolean acceptGzipEncoding,
int timeout)
Open a URL and return an InputStream to it
if acceptGzipEncoding == true, use GZIPEncoding to
compress communication.
|
static InputStream |
getInputStream(URL url,
int timeout)
Connect to server and return result as an InputStream.
|
static URLConnection |
openURLConnection(URL url)
Open HttpURLConnection.
|
static URLConnection |
openURLConnection(URL url,
int timeout)
Open HttpURLConnection.
|
public static final int DEFAULT_CONNECTION_TIMEOUT
public URLConnectionTools()
public static URLConnection openURLConnection(URL url, int timeout) throws IOException
url
- URL to opentimeout
- timeout in milli secondsIOException
- an error in opening the URLpublic static URLConnection openURLConnection(URL url) throws IOException
url
- a URL to open a http connection toIOException
- an error in opening the URLpublic static InputStream getInputStream(URL url, int timeout) throws IOException
The caller is responsible to close the returned InputStream not to cause resource leaks.
url
- the URL to connect totimeout
- the timeout for the connectionInputStream
of responseIOException
- due to an error opening the URLpublic static InputStream getInputStream(URL url) throws IOException
The caller is responsible to close the returned InputStream not to cause resource leaks.
url
- the input URL to be readInputStream
of responseIOException
- due to an error opening the URLpublic static InputStream getInputStream(URL url, boolean acceptGzipEncoding, int timeout) throws IOException
The caller is responsible to close the returned InputStream not to cause resource leaks.
url
- the input URL to be readacceptGzipEncoding
- whether to accept Gzip encodingtimeout
- InputStream
of responseIOException
- due to an error opening the URLpublic static InputStream doPOST(URL url, String data) throws IOException
The caller is responsible to close the returned InputStream not to cause resource leaks.
url
- the input URL to be readdata
- the post dataInputStream
of responseIOException
- due to an error opening the URLpublic static InputStream doPOST(URL url, String data, int timeout) throws IOException
The caller is responsible to close the returned InputStream not to cause resource leaks.
url
- the input URL to be readdata
- the post datatimeout
- InputStream
of responseIOException
- due to an error opening the URLCopyright © 2000–2018 BioJava. All rights reserved.