final int BUFFER_SIZE = 1024;
BufferedReader bufferedReader;
try {
bufferedReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new DatasetException(
"Platform doesn't support UTF-8. It must!", e);
}
char[] buffer = new char[BUFFER_SIZE];
StringBuilder stringBuilder = new StringBuilder(BUFFER_SIZE);
int bytesRead = 0;
try {
while ((bytesRead = bufferedReader.read(buffer, 0, BUFFER_SIZE)) > 0) {
stringBuilder.append(buffer, 0, bytesRead);
}
} catch (IOException e) {
throw new DatasetException("Error reading from input stream", e);
}
return stringBuilder.toString();
}