request getreader 28 29

Solutions on MaxInterview for request getreader 28 29 by the best coders in the world

showing results for - "request getreader 28 29"
Alonso
21 Mar 2016
1IOUtils.toString(request.getReader())
Emily
27 Apr 2016
1public static String getBody(HttpServletRequest request) throws IOException {
2
3    String body = null;
4    StringBuilder stringBuilder = new StringBuilder();
5    BufferedReader bufferedReader = null;
6
7    try {
8        InputStream inputStream = request.getInputStream();
9        if (inputStream != null) {
10            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
11            char[] charBuffer = new char[128];
12            int bytesRead = -1;
13            while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
14                stringBuilder.append(charBuffer, 0, bytesRead);
15            }
16        } else {
17            stringBuilder.append("");
18        }
19    } catch (IOException ex) {
20        throw ex;
21    } finally {
22        if (bufferedReader != null) {
23            try {
24                bufferedReader.close();
25            } catch (IOException ex) {
26                throw ex;
27            }
28        }
29    }
30
31    body = stringBuilder.toString();
32    return body;
33}
Ulysse
15 May 2019
1// Read from request
2    StringBuilder buffer = new StringBuilder();
3    BufferedReader reader = request.getReader();
4    String line;
5    while ((line = reader.readLine()) != null) {
6        buffer.append(line);
7    }
8    String data = buffer.toString()