Skip to content

Instantly share code, notes, and snippets.

View kingreatwill's full-sized avatar
🌴
On vacation

wcoder.com kingreatwill

🌴
On vacation
View GitHub Profile
@kingreatwill
kingreatwill / ParseRequestBodyToBytes.java
Created May 24, 2022 03:28 — forked from yanhua365/ParseRequestBodyToBytes.java
从HTTP Request里取得body内容得到byte数组的方法。
public byte[] parse(HttpServletRequest request) {
byte[] input = null;
try {
InputStream is = request.getInputStream();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
while (true) {
int c = is.read();
if (c == -1) break;
byteStream.write((byte) c);