try{
url = new URL(urls[0]);
connection = (HttpURLConnection) url.openConnection();
connection.connect();
InputStream in = connection.getInputStream();
InputStreamReader reader = new InputStreamReader(in);
int data = reader.read();
while(data != -1){
char ch = (char) data;
result+=ch;
data = reader.read();
}
return result;
}catch(Exception e){
e.printStackTrace();
return null;
}
Can anyone please explain me the functioning of this code! Because I'm not getting why we use an integer here to store the stream values and how is the while loop is working here.