HttpUrlConnection的setDoInput(),setDoOutput()

今天头脑有点蒙。做一个listview图文混排的例子,用AsyncTask

conn.setDoInput(true);
conn.setDoOutput(true);

然后运行后报错。

    public Bitmap downLoadImage() {
            Bitmap bitmap = null;

            HttpURLConnection conn = null;
            try {
                URL url = new URL(imageUrl);
                conn = (HttpURLConnection) url.openConnection();
                //这里可以不设置他们
                //conn.setDoInput(true);
                //conn.setDoOutput(false);   setdoinput(true),setdooutput(false);
                conn.setReadTimeout(8000);
                conn.setReadTimeout(10*1000);
                InputStream is = conn.getInputStream();
                bitmap = BitmapFactory.decodeStream(is);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return bitmap;
        }
这里写代码片

你可能感兴趣的:(HttpUrlConnection的setDoInput(),setDoOutput())