The binary data is received by the servlet in Java and then the binary data stream is read as a byte array. Start using:
Byte[] bs = new byte[request.getcontentlength ()];
Request.getinputstream (). read (BS);
return BS;
When the amount of data is small, there is no problem, the data volume is too large to read incomplete, and then modify as follows.
/*** Get the data submitted by the customer *@paramRequest *@return */Private byte[] GetData (HttpServletRequest request) {Try { //byte[] bs = new byte[request.getcontentlength ()]; //Request.getinputstream (). read (BS); //return BS;servletinputstream sis=Request.getinputstream (); Bytearrayoutputstream Swapstream=NewBytearrayoutputstream (); byte[] Buff =New byte[100]; intrc = 0; while(rc = sis.read (buff, 0,)) > 0) {swapstream.write (buff,0, RC); } byte[] in2b =Swapstream.tobytearray (); returnin2b; } Catch(IOException e) {LogHelper.logger.error ("Failed to receive data", E); } return New byte[0];}
Records to facilitate later viewing
Java reads a byte array from the memory stream