9. Working with HTTP
Activity 1: Using the jsoup Library to Download Files from the Web
Solution
The program is relatively short. The main task is to figure out the CSS query for the select()
method call:
- Create a class named
Activity1
. - In
main()
, start atry-catch
blocktry { } catch (IOException e) { e.printStackTrace(); }
- Inside the
try
block, use theJsoup
library to download the contents of the remote Web page located at https://packt.live/2BqZbtq. This will result in the Web page contents stored in aDocument
object.String url = "http://hc.apache.org/"; &...