package com.ls.utils; import jakarta.servlet.http.HttpServletRequest; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; /** * @author Lartimes * @version 1.0 * @description: * @since 2023/10/24 22:04 */ public class HttpGetJson { private HttpGetJson() { } public static String getJson(HttpServletRequest request) { StringBuilder result = new StringBuilder(); BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader( request.getInputStream(), StandardCharsets.UTF_8)); String line; while ((line = in.readLine()) != null) { result.append(line); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (in != null) { in.close(); } } catch (IOException e) { e.printStackTrace(); } } return result.toString(); } }
标签:java,获取,JSON,IOException,result,io,import,Http,null From: https://www.cnblogs.com/lartimes/p/17878555.html