Do specify the character encoding. Do not waste code, introduce bugs, and slow execution with a BufferedReader
.
Here is an example. You could parameterize it with a buffer size, encoding, etc.
static String readString(InputStream is) throws IOException {
char[] buf = new char[2048];
Reader r = new InputStreamReader(is, "UTF-8");
StringBuilder s = new StringBuilder();
while (true) {
int n = r.read(buf);
if (n < 0)
break;
s.append(buf, 0, n);
}
return s.toString();
}