0
down vote
favorite
I am trying to use JSoup to open a list of links I've stored in an ArrayList named arrayLinks. When I run the code to open a link in the ArrayList, I get a Malformed URL Exception.However, if I take the Malformed Links and hardcode them into the application, I get no errors. I have tried looking at several other posts using StringFormatters or UTF-8, but nothing seems to work. Any suggestions would be greatly appreciated. Thanks!
Code that Doesn't Work:
article = Jsoup.connect(arrayLinks.get(i)).get()
Error:
Caused by: java.net.MalformedURLException: no protocol: "https://www.sbnation.com/college-football-recruiting/2014/7/3/5715252/cordell-broadus-recruit-scouting-report-sure-handed-receiver"
at java.base/java.net.URL.<init>(URL.java:627)
at java.base/java.net.URL.<init>(URL.java:523)
at java.base/java.net.URL.<init>(URL.java:470)
at org.jsoup.helper.HttpConnection.url(HttpConnection.java:132)
0 down vote favorite I am trying to use JSoup to open a list of links I've stored in an ArrayList named arrayLinks. When I run the code to open a link in the ArrayList, I get a Malformed URL Exception.However, if I take the Malformed Links and hardcode them into the application, I get no errors. I have tried looking at several other posts using StringFormatters or UTF-8, but nothing seems to work. Any suggestions would be greatly appreciated. Thanks!
Code that Doesn't Work:
article = Jsoup.connect(arrayLinks.get(i)).get()
Error:
Code that Works:
article = Jsoup.connect("https://www.sbnation.com/college-football-recruiting/2014/7/3/5715252/cordell-broadus-recruit-scouting-report-sure-handed-receiver").get()
There seems to be an error in the way that JSoup is processing the entries of the ArrayList.