org.das2.util.filesystem.HtmlUtil
checkRedirect
checkRedirect( java.net.URLConnection urlConnection ) → URLConnection
check for 301, 302 or 303 redirects, and return a new connection in this case.
This should be called immediately before the urlConnection.connect call,
as this must connect to get the response code.
Parameters
urlConnection - if an HttpUrlConnection, check for 301 or 302; return connection otherwise.
Returns:
a connection, typically the same one as passed in.
See Also:
HttpUtil#checkRedirect(java.net.URLConnection)
search for examples
view on GitHub
view source
consumeStream
consumeStream( java.io.InputStream err ) → void
nice clients consume both the stderr and stdout coming from websites.
This reads everything off of the stream and closes it.
http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html suggests that you "do not abandon connection"
Parameters
err - the input stream
Returns:
void (returns nothing)
See Also:
HttpUtil#consumeStream(java.io.InputStream)
search for examples
view on GitHub
view source
getDirectoryListing
getDirectoryListing( java.net.URL url, java.io.InputStream urlStream ) → URL
Get the listing of the web directory, returning links that are "under" the given URL.
Note this does not handle off-line modes where we need to log into
a website first, as is often the case for a hotel.
This was refactored to support caching of listings by simply writing the content to disk.
Parameters
url - the address.
urlStream - stream containing the URL content, which must be UTF-8 (or US-ASCII)
Returns:
list of URIs referred to in the page.
search for examples
view on GitHub
view source