|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasen.util.WebUtils
General WWW and net utility methods.
Field Summary | |
static String |
URL_REGEX
|
Constructor Summary | |
WebUtils()
|
Method Summary | |
static void |
get(URL url,
OutputStream out,
int bufferSize,
long timeout)
Attempts to download the file given by the URL and saves it to the output stream provided NOTE: The given output stream will NOT be closed within this method |
static void |
get(URL url,
OutputStream out,
int bufferSize,
long timeout,
StreamReaderListener listener)
Attempts to download the file given by the URL and saves it to the output stream provided NOTE: The given output stream will NOT be closed within this method |
static boolean |
isUrl(String text)
Returns true iff the text passed represents a url. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String URL_REGEX
Constructor Detail |
public WebUtils()
Method Detail |
public static boolean isUrl(String text)
A url may take many forms:
For example:
Unfortunately there doesn't seem to be an "elegant" way to determine
definatively if an unknown String is in fact a URL. We are just going
to use the java.net.URL class and assume a MalformedURLException implies
that the string is not a url.
text
-
public static void get(URL url, OutputStream out, int bufferSize, long timeout) throws IOException
url
- The fully qualified url path to the remote resourceout
- The output stream to which the data read will be writtenbufferSize
- The buffer size to use for reading bytestimeout
- The timeout (in milliseconds) to wait for a response from the remote server
IOException
- If an error occurred during transitpublic static void get(URL url, OutputStream out, int bufferSize, long timeout, StreamReaderListener listener) throws IOException
url
- The fully qualified url path to the remote resourceout
- The output stream to which the data read will be writtenbufferSize
- The buffer size to use for reading bytestimeout
- The timeout (in milliseconds) to wait for a response from the remote serverlistener
- A listener which will report when bytes have been written to the output stream
IOException
- If an error occurred during transit
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |