Android复习04(适配器 Get()请求 适配器 getView()方法 Post()请求 保存Cookie 流转字符串 从网上获取图片 重点考Json解析)

目   录

适配器

Get()请求

适配器 getView()方法

Post()请求

保存Cookie

流转字符串

从网上获取图片

重点考Json解析


适配器

Get()请求

适配器 getView()方法

Post()请求

保存Cookie

流转字符串

    /**
     * 将流转为字符串
     * @param inStream  输入流
     * @return  返回字符串
     * @throws IOException
     */
    private static String is2String(InputStream inStream) throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        while((len = inStream.read(buffer)) != -1)
        {
            outStream.write(buffer,0,len);
        }
        inStream.close();
        return new String(outStream.toByteArray(), "UTF-8");
    }
    private static String is2String2(InputStream inStream) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(inStream,"utf-8"));
        StringBuffer sb=new StringBuffer();
        String line;
        while ((line=br.readLine())!=null){
            sb.append(line);
        }
        br.close();
        inStream.close();
        return sb.toString();
    }

从网上获取图片

重点考Json解析

猜你喜欢

转载自blog.csdn.net/weixin_44949135/article/details/106190413
今日推荐