I am trying to read a response from server using HttpsURLConnection
.
InputStreamReader in = new InputStreamReader((InputStream) con.getContent());
BufferedReader buff = new BufferedReader(in);
String line;
StringBuilder response=new StringBuilder();
long st=System.nanoTime();
while ((line =buff.readLine())!= null) {
response=response.append(line +"\n");
}
long et=System.nanoTime();
System.out.println("resp process time: "+((et-st))+" ns");
return response.toString();
}
Currently, it takes approximately 450 ms to read the entire response consisting about 80000 characters( 1100 lines).
Output: resp process time: 435272240 ns
Would it be possible to optimize this code further to reduce processing time?