I am using URLConnection in Java to get the response of the webpage. I dont want to use JSoup.
When using the below code, I am getting the whole response as a single line like below.
<html><head><stylesheet>something,something,something,</stylesheet><script>something,something,something,something</script></head><body>something,something,something,something,something </body></html>
But I want to get them like below
<html>
<head>
<stylesheet>
something,
something,
something
</stylesheet>
<script>
something,
something,
something,
something
</script>
</head>
<body>
something,
something,
something,
something,
something
</body>
</html>
Here is the code I am using,
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
InputStream content = (InputStream) connection.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = in.readLine()) != null) {
String s = line.toString();
System.out.println(s);
}