|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.switchboard.util.NetUtil
public class NetUtil
A collection of network-related static functions.
| Constructor Summary | |
|---|---|
NetUtil()
|
|
| Method Summary | |
|---|---|
static boolean |
exists(String url)
Checks to see if a remote file exists. |
static String |
getFileAsString(URL url)
Gets the contents of a URL as a string. |
static String |
getInputStreamAsString(InputStream is)
Gets the contents of an input stream as a String |
static String[] |
getIPs(URL url)
Parses a document and returns any IP addresses that appear on it. |
static String[] |
getURLs(String text)
|
static String |
getVarFromUrl(String url,
String key)
Gets a particular value from a URL with variables in it |
static Map |
getVarsFromURL(String url)
Parses a URL, picking out the key/value pairs |
static boolean |
hasContents(String url)
|
boolean |
isValidURL(String url)
|
static String |
makeRestRequest(String endpoint,
Map params)
Makes a REST request URI out of an endpoint and a hashmap of parameters |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NetUtil()
| Method Detail |
|---|
public static String getFileAsString(URL url)
throws IOException,
MalformedURLException
url - The URL to fetch.
IOException - If the document cannot be found.
MalformedURLException - If a bad URL is given.
public static String getInputStreamAsString(InputStream is)
throws IOException
is - the InputStream to read from
IOException - If the page can't be found.
public static String[] getIPs(URL url)
throws IOException
url - The URL of the page to search.
IOException - If the parser cannot open the document.public static String[] getURLs(String text)
public static String makeRestRequest(String endpoint,
Map params)
endpoint - The endpoint of the REST service.params - A list of params, with the variable name as the hashmap key,
and the value as the hashmap value
MalformedURLException - If the endpoint is a bad URL.public static boolean hasContents(String url)
public static boolean exists(String url)
url - The URL to check
public static Map getVarsFromURL(String url)
url - The URL to parse
public static String getVarFromUrl(String url,
String key)
url - The URL to parsekey - The variable key
public boolean isValidURL(String url)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||