`
String message, line;
for (; {
line = in.readLine();
message += line;
}
`
Time taken to download a 1500 line email: 13 secs
Oh dear. Java is so slow! (Reads API…) What’s this StringBuffer all about then?
`
StringBuffer message;
String line;
for (; {
line = in.readLine();
message.append(line);
}
`
Time taken to download a 1500 line email: 50ms
Hurrah! Java is fast!
I wish all optimisations were as easy as this!