I was trying to get some HTML by URL and put it into String. This is my effort:
public class
Bank {
public static void main(String[] args) throws IOException {
URL hh = new URL("https://m.hh.ru/");
BufferedReader in = new BufferedReader(
new InputStreamReader(hh.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
inputLine.concat(inputLine);//returns null. WTF?
System.out.println(inputLine);
}
in.close();
System.out.println(inputLine);
}
}
As I said I want to put it to inputLine, but it returns NULL.
What's wrong?
Stringsare immutable. UseStringBuilderinstead.in.readLinewill setinputLinetonull.