I have below code.
Content is coming in request which is non english and UTF-8 encoded. How to read it ? Currently i am doing this but looks like it is not correct.
private String readContent(HttpServletRequest request) throws IOException {
String body = null;
BufferedReader reader = null;
if (logger.isDebugEnabled()) {
logger.debug("Inside readContent() ...");
}
try {
// Read from request
StringBuilder buffer = new StringBuilder();
reader = request.getReader();
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line + "\n");
}
// if (body != null) {
body = buffer.toString();
body.trim();
// }
} catch (IOException ex) {
throw ex;
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
throw ex;
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Leaving readContent() ..." + body);
}
return body;
}