Reading inputStream using BufferedReader.readLine() is too slow

I strongly suspect that’s because of the network connection or the web server you’re talking to – it’s not BufferedReader‘s fault. Try measuring this:

InputStream stream = conn.getInputStream();
byte[] buffer = new byte[1000];
// Start timing
while (stream.read(buffer) > 0)
{
}
// End timing

I think you’ll find it’s almost exactly the same time as when you’re parsing the text.

Note that you should also give InputStreamReader an appropriate encoding – the platform default encoding is almost certainly not what you should be using.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)