Package ucar.unidata.io
Class ReadFromUrl
- java.lang.Object
-
- ucar.unidata.io.ReadFromUrl
-
public class ReadFromUrl extends Object
Note: checks for gzip. Shouldnt that be handled automatically? Static utility methods that read from URLs, using URLConnection. Could replace with java.net.http.HttpClient. Only used in ToolUI?
-
-
Constructor Summary
Constructors Constructor Description ReadFromUrl()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
copyUrlB(String urlString, OutputStream out, int bufferSize)
copy contents of URL to output stream, specify internal buffer size.static InputStream
getInputStreamFromUrl(String urlString)
get input stream from URLstatic String
readURLcontents(String urlString)
Read the contents from the named URL and place into a String.
-
-
-
Method Detail
-
copyUrlB
public static long copyUrlB(String urlString, OutputStream out, int bufferSize) throws IOException
copy contents of URL to output stream, specify internal buffer size. request gzip encoding- Parameters:
urlString
- copy the contents of this URLout
- copy to this stream. If null, throw bytes awaybufferSize
- internal buffer size.- Returns:
- number of bytes copied
- Throws:
IOException
- on io error
-
getInputStreamFromUrl
public static InputStream getInputStreamFromUrl(String urlString) throws IOException
get input stream from URL- Parameters:
urlString
- URL- Returns:
- input stream, unzipped if needed
- Throws:
IOException
- on io error
-
readURLcontents
public static String readURLcontents(String urlString) throws IOException
Read the contents from the named URL and place into a String.- Parameters:
urlString
- the URL to read from.- Returns:
- String holding the contents.
- Throws:
IOException
- if fails
-
-