zoukankan      html  css  js  c++  java
  • 将流中的数据转换成字符串

    public class StreamTools {

        public static String readFromStream(InputStream is) throws Exception {

           ByteArrayOutputStream baos = new ByteArrayOutputStream();

            byte[] buffer = new byte[1024];

              int len = 0;

              while ((len = is.read(buffer)) != -1) {

                    baos.write(buffer, 0, len);

                    }

                 is.close();

                 String result = baos.toString();

                 baos.close(); return result;

    }

    看不清未来,就做好现在,,,
  • 相关阅读:
    UVa 106
    UVa 111
    UVa 105
    UVa 104
    UVa 103
    UVa 102
    UVa 101
    UVa 100
    就决定是你了!
    阿姆斯特朗回旋加速喷气式阿姆斯特朗炮
  • 原文地址:https://www.cnblogs.com/gsdimz/p/3132358.html
Copyright © 2011-2022 走看看