public class NetworkUtil extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
NetworkUtil.InternetAccessListener |
static class |
NetworkUtil.WeakInternetAccessListener
Weak listener wrapper for NetworkConnectionListener.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ID_BETAALLOWED |
static java.lang.String |
ID_DEVELOPERID |
static java.lang.String |
ID_ERRORLOG |
static java.lang.String |
ID_JAVABITS |
static java.lang.String |
ID_JAVANAME |
static java.lang.String |
ID_JAVAVERSION |
static java.lang.String |
ID_KERNELVERSION
Parameters id
|
static java.lang.String |
ID_OSARCH |
static java.lang.String |
ID_OSNAME |
static java.lang.String |
ID_OSVERSION |
static java.lang.String |
ID_PLUGINCLASSNAME |
static java.lang.String |
ID_PLUGINVERSION |
static icy.network.NetworkUtil.InternetMonitorThread |
internetMonitor
Internet monitor
|
static int |
NO_PROXY
Proxy config ID
|
static int |
SYSTEM_PROXY |
static int |
USER_PROXY |
static java.lang.String |
WEBSITE_HOST
URL
|
static java.lang.String |
WEBSITE_URL |
Constructor and Description |
---|
NetworkUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addInternetAccessListener(NetworkUtil.InternetAccessListener listener)
Adds a new listener on internet access change.
|
static boolean |
connect(java.net.URLConnection uc,
boolean displayError)
Connect the specified
URLConnection . |
static void |
disableCache(java.net.URLConnection uc) |
static void |
disableFTPProxySetting() |
static void |
disableHTTPProxySetting() |
static void |
disableHTTPSProxySetting() |
static void |
disableProxySetting() |
static void |
disableSOCKSProxySetting() |
static void |
disableSystemProxy() |
static byte[] |
download(java.io.File f,
ProgressListener listener,
boolean displayError)
Download data from File and return it as an array of byte.
|
static byte[] |
download(java.io.InputStream in)
Download data from specified InputStream and return it as an array of byte.
|
static byte[] |
download(java.io.InputStream in,
long len,
ProgressListener listener)
Download data from specified InputStream and return it as an array of byte.
|
static byte[] |
download(java.lang.String path,
ProgressListener listener,
boolean displayError)
Download data from specified URL string and return it as an array of byte
|
static byte[] |
download(java.lang.String path,
java.lang.String login,
java.lang.String pass,
ProgressListener listener,
boolean displayError)
Download data from specified URL string and return it as an array of byte
Process authentication process if login / pass are not null.
|
static byte[] |
download(java.net.URL url,
ProgressListener listener,
boolean displayError)
Download data from specified URL and return it as an array of byte
|
static byte[] |
download(java.net.URL url,
java.lang.String login,
java.lang.String pass,
ProgressListener listener,
boolean displayError)
Download data from specified URL and return it as an array of byte.
|
static void |
enableFTPProxySetting() |
static void |
enableHTTPProxySetting() |
static void |
enableHTTPSProxySetting() |
static void |
enableProxySetting() |
static void |
enableSOCKSProxySetting() |
static void |
enableSystemProxy() |
static java.lang.String |
getContentString(java.util.HashMap<java.lang.String,java.lang.String> values)
Deprecated.
Use
getContentString(Map) instead. |
static java.lang.String |
getContentString(java.util.Map<java.lang.String,java.lang.String> values) |
static java.lang.String |
getFTPProxyHost() |
static int |
getFTPProxyPort() |
static java.lang.String |
getHTTPProxyHost() |
static int |
getHTTPProxyPort() |
static java.lang.String |
getHTTPSProxyHost() |
static int |
getHTTPSProxyPort() |
static java.io.InputStream |
getInputStream(java.net.URL url,
AuthenticationInfo auth,
boolean disableCache,
boolean displayError)
Returns a new
InputStream from specified URL (null if an error occurred). |
static java.io.InputStream |
getInputStream(java.net.URLConnection uc,
boolean displayError)
Returns a new
InputStream from specified URLConnection (null if an error
occurred). |
static java.io.InputStream |
getInputStream(java.net.URL url,
java.lang.String login,
java.lang.String pass,
boolean disableCache,
boolean displayError)
Returns a new
InputStream from specified URL (null if an error occurred). |
static java.lang.String |
getProxyHost() |
static int |
getProxyPort() |
static java.lang.String |
getSOCKSProxyHost() |
static int |
getSOCKSProxyPort() |
static boolean |
hasInternetAccess()
Returns true if we currently have Internet connection.
|
static boolean |
hasInternetConnection()
Deprecated.
Use
hasInternetAccess() instead. |
static void |
init() |
static boolean |
isHTTPSSupported()
Returns true if HTTPS is supported for the new web site.
|
static boolean |
openBrowser(java.lang.String url)
Open an URL in the default system browser
|
static boolean |
openBrowser(java.net.URI uri)
Open an URL in the default system browser
|
static boolean |
openBrowser(java.net.URL url)
Open an URL in the default system browser
|
static java.net.URLConnection |
openConnection(java.lang.String path,
boolean disableCache,
boolean displayError)
Returns a new
URLConnection from specified path. |
static java.net.URLConnection |
openConnection(java.net.URL url,
AuthenticationInfo auth,
boolean disableCache,
boolean displayError)
Returns a new
URLConnection from specified URL (null if an error occurred). |
static java.net.URLConnection |
openConnection(java.net.URL url,
boolean disableCache,
boolean displayError)
Returns a new
URLConnection from specified URL (null if an error occurred). |
static java.net.URLConnection |
openConnection(java.net.URL url,
java.lang.String login,
java.lang.String pass,
boolean disableCache,
boolean displayError)
Returns a new
URLConnection from specified URL (null if an error occurred). |
static java.net.URLConnection |
openConnection(java.net.URL url,
java.lang.String login,
java.lang.String pass,
boolean disableCache,
boolean doConnect,
boolean displayError)
Returns a new
URLConnection from specified URL (null if an error occurred). |
static void |
openURL(java.lang.String url)
Deprecated.
Use
openBrowser(String) instead. |
static void |
openURL(java.net.URI uri)
Deprecated.
Use
openBrowser(URI) instead. |
static void |
openURL(java.net.URL url)
Deprecated.
Use
openBrowser(URL) instead. |
static java.lang.String |
postData(java.lang.String target,
java.util.HashMap<java.lang.String,java.lang.String> values)
Deprecated.
Use
postData(String, Map) instead. |
static java.lang.String |
postData(java.lang.String target,
java.util.HashMap<java.lang.String,java.lang.String> values,
java.lang.String login,
java.lang.String pass)
Deprecated.
Use
postData(String, Map, String, String) instead. |
static java.lang.String |
postData(java.lang.String target,
java.util.Map<java.lang.String,java.lang.String> values) |
static java.lang.String |
postData(java.lang.String target,
java.util.Map<java.lang.String,java.lang.String> values,
java.lang.String login,
java.lang.String pass) |
static java.lang.String |
postData(java.lang.String target,
java.lang.String content) |
static java.lang.String |
postData(java.lang.String target,
java.lang.String content,
java.lang.String login,
java.lang.String pass) |
static void |
removeInternetAccessListener(NetworkUtil.InternetAccessListener listener)
Removes a listener on internet access change.
|
static void |
report(java.util.HashMap<java.lang.String,java.lang.String> values)
Deprecated.
Use
report(Map) instead. |
static void |
report(java.util.Map<java.lang.String,java.lang.String> values)
Send report (asynchronous processing)
|
static void |
setAuthentication(java.net.URLConnection uc,
java.lang.String login,
java.lang.String pass)
Process authentication on specified
URLConnection with specified login and pass. |
static void |
setFTPProxyHost(java.lang.String host) |
static void |
setFTPProxyPassword(java.lang.String password) |
static void |
setFTPProxyPort(int port) |
static void |
setFTPProxyUser(java.lang.String user) |
static void |
setHTTPProxyHost(java.lang.String host) |
static void |
setHTTPProxyPassword(java.lang.String password) |
static void |
setHTTPProxyPort(int port) |
static void |
setHTTPProxyUser(java.lang.String user) |
static void |
setHTTPSProxyHost(java.lang.String host) |
static void |
setHTTPSProxyPassword(java.lang.String password) |
static void |
setHTTPSProxyPort(int port) |
static void |
setHTTPSProxyUser(java.lang.String user) |
static void |
setProxyHost(java.lang.String host) |
static void |
setProxyPort(int port) |
static void |
setSOCKSProxyHost(java.lang.String host) |
static void |
setSOCKSProxyPassword(java.lang.String password) |
static void |
setSOCKSProxyPort(int port) |
static void |
setSOCKSProxyUser(java.lang.String user) |
static void |
updateNetworkSetting()
Update network setting from the actual preferences
|
public static final java.lang.String WEBSITE_HOST
public static final java.lang.String WEBSITE_URL
public static final java.lang.String ID_KERNELVERSION
public static final java.lang.String ID_BETAALLOWED
public static final java.lang.String ID_JAVANAME
public static final java.lang.String ID_JAVAVERSION
public static final java.lang.String ID_JAVABITS
public static final java.lang.String ID_OSNAME
public static final java.lang.String ID_OSVERSION
public static final java.lang.String ID_OSARCH
public static final java.lang.String ID_PLUGINCLASSNAME
public static final java.lang.String ID_PLUGINVERSION
public static final java.lang.String ID_DEVELOPERID
public static final java.lang.String ID_ERRORLOG
public static final int NO_PROXY
public static final int SYSTEM_PROXY
public static final int USER_PROXY
public static final icy.network.NetworkUtil.InternetMonitorThread internetMonitor
public NetworkUtil()
public static void init()
public static void updateNetworkSetting()
public static void addInternetAccessListener(NetworkUtil.InternetAccessListener listener)
public static void removeInternetAccessListener(NetworkUtil.InternetAccessListener listener)
public static boolean hasInternetAccess()
@Deprecated public static boolean hasInternetConnection()
hasInternetAccess()
instead.public static boolean isHTTPSSupported()
public static boolean openBrowser(java.lang.String url)
public static boolean openBrowser(java.net.URL url)
public static boolean openBrowser(java.net.URI uri)
@Deprecated public static void openURL(java.lang.String url)
openBrowser(String)
instead.@Deprecated public static void openURL(java.net.URL url)
openBrowser(URL)
instead.@Deprecated public static void openURL(java.net.URI uri)
openBrowser(URI)
instead.public static byte[] download(java.lang.String path, ProgressListener listener, boolean displayError)
public static byte[] download(java.lang.String path, java.lang.String login, java.lang.String pass, ProgressListener listener, boolean displayError)
public static byte[] download(java.net.URL url, ProgressListener listener, boolean displayError)
public static byte[] download(java.net.URL url, java.lang.String login, java.lang.String pass, ProgressListener listener, boolean displayError)
null
if an error occurred.public static byte[] download(java.io.File f, ProgressListener listener, boolean displayError)
null
if an error occurred (file not found or not existing, IO
error...)public static byte[] download(java.io.InputStream in, long len, ProgressListener listener) throws java.io.IOException
null
if load operation was interrupted by user.java.io.IOException
public static byte[] download(java.io.InputStream in) throws java.io.IOException
null
if an error occurred.java.io.IOException
public static java.net.URLConnection openConnection(java.net.URL url, java.lang.String login, java.lang.String pass, boolean disableCache, boolean doConnect, boolean displayError)
URLConnection
from specified URL (null if an error occurred).url
- url to connect.login
- login if the connection requires authentication.pass
- login if the connection requires authentication.
Set it to null if no authentication needed.disableCache
- Disable proxy cache if any.doConnect
- do the connection before return the URLConnection
objectdisplayError
- Display error message in console if something wrong happen.public static java.net.URLConnection openConnection(java.net.URL url, java.lang.String login, java.lang.String pass, boolean disableCache, boolean displayError)
URLConnection
from specified URL (null if an error occurred).url
- url to connect.login
- login if the connection requires authentication.pass
- login if the connection requires authentication.
Set it to null if no authentication needed.disableCache
- Disable proxy cache if any.displayError
- Display error message in console if something wrong happen.public static java.net.URLConnection openConnection(java.net.URL url, AuthenticationInfo auth, boolean disableCache, boolean displayError)
URLConnection
from specified URL (null if an error occurred).url
- url to connect.auth
- Authentication informations.disableCache
- Disable proxy cache if any.displayError
- Display error message in console if something wrong happen.public static java.net.URLConnection openConnection(java.net.URL url, boolean disableCache, boolean displayError)
URLConnection
from specified URL (null if an error occurred).url
- url to connect.disableCache
- Disable proxy cache if any.displayError
- Display error message in console if something wrong happen.public static java.net.URLConnection openConnection(java.lang.String path, boolean disableCache, boolean displayError)
URLConnection
from specified path.null
if an error occurred.path
- path to connect.disableCache
- Disable proxy cache if any.displayError
- Display error message in console if something wrong happen.public static boolean connect(java.net.URLConnection uc, boolean displayError)
URLConnection
.uc
- URLConnection to connect.displayError
- Display error message in console if something wrong happen.public static java.io.InputStream getInputStream(java.net.URLConnection uc, boolean displayError)
InputStream
from specified URLConnection
(null if an error
occurred).uc
- URLConnection object.displayError
- Display error message in console if something wrong happen.public static java.io.InputStream getInputStream(java.net.URL url, java.lang.String login, java.lang.String pass, boolean disableCache, boolean displayError)
InputStream
from specified URL (null if an error occurred).url
- url we want to connect and retrieve the InputStream.login
- login if the connection requires authentication.pass
- login if the connection requires authentication.
Set it to null if no authentication needed.disableCache
- Disable proxy cache if any.displayError
- Display error message in console if something wrong happen.public static java.io.InputStream getInputStream(java.net.URL url, AuthenticationInfo auth, boolean disableCache, boolean displayError)
InputStream
from specified URL (null if an error occurred).url
- url we want to connect and retrieve the InputStream.auth
- Authentication informations.disableCache
- Disable proxy cache if any.displayError
- Display error message in console if something wrong happen.public static void disableCache(java.net.URLConnection uc)
public static void setAuthentication(java.net.URLConnection uc, java.lang.String login, java.lang.String pass)
URLConnection
with specified login and pass.public static java.lang.String getContentString(java.util.Map<java.lang.String,java.lang.String> values)
public static java.lang.String postData(java.lang.String target, java.util.Map<java.lang.String,java.lang.String> values, java.lang.String login, java.lang.String pass) throws java.io.IOException
java.io.IOException
public static java.lang.String postData(java.lang.String target, java.lang.String content, java.lang.String login, java.lang.String pass) throws java.io.IOException
java.io.IOException
public static java.lang.String postData(java.lang.String target, java.util.Map<java.lang.String,java.lang.String> values) throws java.io.IOException
java.io.IOException
public static java.lang.String postData(java.lang.String target, java.lang.String content) throws java.io.IOException
java.io.IOException
public static void report(java.util.Map<java.lang.String,java.lang.String> values)
values
- list of @Deprecated public static java.lang.String getContentString(java.util.HashMap<java.lang.String,java.lang.String> values)
getContentString(Map)
instead.@Deprecated public static java.lang.String postData(java.lang.String target, java.util.HashMap<java.lang.String,java.lang.String> values, java.lang.String login, java.lang.String pass) throws java.io.IOException
postData(String, Map, String, String)
instead.java.io.IOException
@Deprecated public static java.lang.String postData(java.lang.String target, java.util.HashMap<java.lang.String,java.lang.String> values) throws java.io.IOException
postData(String, Map)
instead.java.io.IOException
@Deprecated public static void report(java.util.HashMap<java.lang.String,java.lang.String> values)
report(Map)
instead.public static void enableSystemProxy()
public static void disableSystemProxy()
public static void enableProxySetting()
public static void disableProxySetting()
public static void enableHTTPProxySetting()
public static void disableHTTPProxySetting()
public static void enableHTTPSProxySetting()
public static void disableHTTPSProxySetting()
public static void enableFTPProxySetting()
public static void disableFTPProxySetting()
public static void enableSOCKSProxySetting()
public static void disableSOCKSProxySetting()
public static void setProxyHost(java.lang.String host)
public static void setProxyPort(int port)
public static void setHTTPProxyHost(java.lang.String host)
public static void setHTTPProxyPort(int port)
public static void setHTTPProxyUser(java.lang.String user)
public static void setHTTPProxyPassword(java.lang.String password)
public static void setHTTPSProxyHost(java.lang.String host)
public static void setHTTPSProxyPort(int port)
public static void setHTTPSProxyUser(java.lang.String user)
public static void setHTTPSProxyPassword(java.lang.String password)
public static void setFTPProxyHost(java.lang.String host)
public static void setFTPProxyPort(int port)
public static void setFTPProxyUser(java.lang.String user)
public static void setFTPProxyPassword(java.lang.String password)
public static void setSOCKSProxyHost(java.lang.String host)
public static void setSOCKSProxyPort(int port)
public static void setSOCKSProxyUser(java.lang.String user)
public static void setSOCKSProxyPassword(java.lang.String password)
public static java.lang.String getProxyHost()
public static int getProxyPort()
public static java.lang.String getHTTPProxyHost()
public static int getHTTPProxyPort()
public static java.lang.String getHTTPSProxyHost()
public static int getHTTPSProxyPort()
public static java.lang.String getFTPProxyHost()
public static int getFTPProxyPort()
public static java.lang.String getSOCKSProxyHost()
public static int getSOCKSProxyPort()