/**
 * java获取raw
 */
public static String readRaw(InputStream inputStream) {

    String result = "";
    try {
        ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];

        int len;
        while ((len = inputStream.read(buffer)) != -1) {
            outSteam.write(buffer, 0, len);
        }

        outSteam.close();
        inputStream.close();

        result = new String(outSteam.toByteArray(), "UTF-8");

    } catch (IOException e) {
        e.printStackTrace();
    }

    return result;
}

  

调用:

String result = FileUtils.readRaw(request.getInputStream());  //result就是raw中的数据

  

相关文章:

  • 2021-08-20
  • 2021-08-18
  • 2021-08-25
  • 2021-07-08
  • 2021-12-31
  • 2021-09-19
  • 2021-05-26
  • 2021-12-02
猜你喜欢
  • 2021-09-28
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2021-10-22
  • 2021-09-28
相关资源
相似解决方案