swen922

Untitled

Mar 20th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public String getInputString(HttpServletRequest req) {
  2.         String receivedString = "";
  3.  
  4.         int len = req.getContentLength();
  5.         byte[] input = new byte[len];
  6.  
  7.         try {
  8.             ServletInputStream sin = req.getInputStream();
  9.             int c = 0;
  10.             int count = 0;
  11.             while ((c = sin.read(input, count, (input.length - count))) > 0) {
  12.                 count += 1;
  13.             }
  14.             sin.close();
  15.         } catch (IOException e) {
  16.            
  17.         }
  18.  
  19.         receivedString = new String(input);
  20.  
  21.         return receivedString;
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment