title: How to read the blob data from servlet request object
body: <p>There is client and server components, the client is sending the data in more secure way by converting the data in blob using POST method to the server.</p>
  
  <p>Can any suggest me how to convert that blob data to string object in server side(Java).i have tried some code below</p>
  
  <pre><code>         Way 1):
          ==============================
          String streamLength = request.getHeader("Content-Length");
          int streamIntLength = Integer.parseInt(streamLength);
          byte[] bytes = new byte[streamIntLength];
          request.getInputStream().read(bytes, 0, bytes.length);
          String content = DatatypeConverter.printBase64Binary(bytes);
          System.out.println(content);
  
          Output for above code is  : some junk data is displaying.
  
          dABlAG0AcABsAGEAdABlAD0AMgAzADUAUgBfAFAAcgBvAHYAaQBkAGUAcgBfA
  
          Way 2) : 
          ======
          BufferedReader reader = new BufferedReader(new InputStreamReader(
          request.getInputStream()));
          StringBuilder sb = new StringBuilder();
          for (String line; (line = reader.readLine()) != null;) {
             String str = new String(line.getBytes());
             System.out.println(str);
          }
  
          Please suggest me any one, above both ways are not worked out.
  </code></pre>