Java Завантажити сайт

2075 / Java / Завантажити сайт


  URL url;
  InputStream is = null;
  BufferedReader br;
  String line = "";
  try 
  {
    url = new URL("https://2075.com.ua");
    is = url.openStream(); // throws an IOException
    br = new BufferedReader(new InputStreamReader(is));
    while ((line = br.readLine()) != null)
    {
      System.out.println(line);
    }
  }
  catch (MalformedURLException mue)
  {
    mue.printStackTrace();
  }
  catch (IOException ioe)
  {
    ioe.printStackTrace();
  }
  finally
  {
    try
    {
      if (is != null) is.close();
    }
    catch (IOException ioe)
    {
    }
  }
}