Class 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 Detail

      • ReadFromUrl

        public ReadFromUrl()
    • 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 URL
        out - copy to this stream. If null, throw bytes away
        bufferSize - 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