Read a study from the specified URL.

@param url URL, must not be null
@return a study read from the specified URL
@throws IOException if an I/O error occurs
480411
public static Study readStudy(final URL url) throws IOException {
        checkNotNull(url);
        try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) {
            return readStudy(reader);
        }
    }
867230
public static JSONObject getJSONFromUrlViaGET(String url) {

        JSONObject jObj = null;

        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }

                jObj = new JSONObject(builder.toString());
            } else {
                // Log.e(ParseJSON.class.toString(), "Failed to download file");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jObj;
    }
269166
public static Study readStudy(final File file) throws IOException {
        checkNotNull(file);
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            return readStudy(reader);
        }
    }
1168590
public static InputStream inputStreamFromURL(URL url) throws IOException
    {
        if ("file".equals(url.getProtocol())) {
            /* As per [WSTX-82], can not do this if the path refers
             * to a network drive on windows. This fixes the problem;
             * might not be needed on all platforms (NFS?), but should not
             * matter a lot: performance penalty of extra wrapping is more
             * relevant when accessing local file system.
             */
            String host = url.getHost();
            if (host == null || host.length() == 0) {
                /* One more test: if there are quoted characters, need
                 * to decoded [WSTX-207]:
                 */
                String path = url.getPath();
                if (path.indexOf('%') >= 0) {
                    path = URLDecoder.decode(path, "UTF-8");
                }
                return new FileInputStream(path);
            }
        }
        return url.openStream();
    }
334730
private static HttpURLConnection open(URL url) throws IOException {
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setReadTimeout(TIMEOUT);
        c.setConnectTimeout(TIMEOUT);
        return c;
    }
425932
public static InputStream fromURL(URL url) throws IOException {
		if(url != null) {
			return url.openStream();
		}
		return null;
	}
924208
public static InputStream inputStream(URL url) {
        try {
            return url.openStream();
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
1056227
public static List<String> readLines(URL url, String charset) throws IORuntimeException {
		return readLines(url, charset, new ArrayList<String>());
	}
914793
public static <T extends Collection<String>> T readLines(URL url, String charsetName, T collection) throws IORuntimeException {
		return readLines(url, CharsetUtil.charset(charsetName), collection);
	}
364507
public byte[] simpleGetBytes(String url) throws IOException {
		final AtomicReference<byte[]> bytes = new AtomicReference<>();
		simpleGetInternal(url, inputStream -> {
            try {
                bytes.set(IOUtils.toByteArray(inputStream));
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }, null);

		return bytes.get();
	}
1057174
public static Document parseDocument(String url) throws IOException {
        return Jsoup
                .connect(url)
                .timeout(Constants.PARSING_TIMEOUT)
                .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                .referrer("http://www.google.com")
                .get();
    }
721571
public static BufferedImage read(URL imageUrl) {
		try {
			return ImageIO.read(imageUrl);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
1175388
public static GTRPublicData read(final URL url) throws IOException {
        checkNotNull(url);
        try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) {
            return read(reader);
        }
    }
77100
public static void browse(String url) {
    Preconditions.checkNotNull(url);
    // Ask user to open in their browser using copy-paste
    System.out.println("Please open the following address in your browser:");
    System.out.println("  " + url);
    // Attempt to open it in the browser
    try {
      if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Action.BROWSE)) {
          System.out.println("Attempting to open that address in the default browser now...");
          desktop.browse(URI.create(url));
        }
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, "Unable to open browser", e);
    } catch (InternalError e) {
      // A bug in a JRE can cause Desktop.isDesktopSupported() to throw an
      // InternalError rather than returning false. The error reads,
      // "Can't connect to X11 window server using ':0.0' as the value of the
      // DISPLAY variable." The exact error message may vary slightly.
      LOGGER.log(Level.WARNING, "Unable to open browser", e);
    }
  }
474944
public static Program parse(URL url) throws IOException {
    InputStream in = url.openStream();
    try {
      return TerminalParser.parse(
          program(), new InputStreamReader(in, Charset.forName("UTF-8")), url.toString());
    } finally {
      in.close();
    }
  }
1035049
public static byte[] getContentBytes(String stringUrl) throws IOException {
    URL url = new URL(stringUrl);
    byte[] data = MyStreamUtils.readContentBytes(url.openStream());
    return data;
  }
120852
public static <T> T readUrlAsObject(String url, Class<T> type) {
		String contents = getUrlContents(url);
		ObjectMapper mapper = new ObjectMapper();
		mapper.enableDefaultTyping();

		try {
			return mapper.readValue(contents, type);
		} catch (IOException e) {
			JK.throww(e);
			return null;
		}
	}