zoukankan      html  css  js  c++  java
  • 输入流转换成字符串

        /**
         * 输入流转换成字符串
         * @param is
         * @param destCode
         * @return
         * @throws IOException
         */
        public static String readFromStream(InputStream is,String destCode) throws IOException {
            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(destCode);
            
            baos.close();
            
            return result;
        }
  • 相关阅读:
    2017年3月9日上午学习
    3.17上午
    3.16上午
    3.16下午
    3.15
    2017.3.14
    3.14
    217.3.13上午
    2017.4.7-morning
    2017.4.6-afternoon
  • 原文地址:https://www.cnblogs.com/cbooy/p/4741040.html
Copyright © 2011-2022 走看看