android启动错误,android-打开失败的EISDIR(是目录)..如何解决此...

每当它给我“无法解码流java.io.FileNotFoundException:/:打开失败的EISDIR(是目录)

我怎样才能摆脱这个错误..在我完成的许多任务中,此类都工作得很好!

这是我用来获取位图的类

private class ImageLoaderTask extends AsyncTask, Void, HashMap>{

@Override

protected HashMap doInBackground(HashMap... hm) {

InputStream iStream=null;

String imgUrl = (String) hm[0].get("image");

int position = (Integer) hm[0].get("position");

URL url;

try {

url = new URL(imgUrl);

// Creating an http connection to communicate with url

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

// Connecting to url

urlConnection.connect();

// Reading data from url

iStream = urlConnection.getInputStream();

// Getting Caching directory

File cacheDirectory = getBaseContext().getCacheDir();

// Temporary file to store the downloaded image

File tmpFile = new File(cacheDirectory.getPath() + "/wpta_"+position+".png");

// The FileOutputStream to the temporary file

FileOutputStream fOutStream = new FileOutputStream(tmpFile);

// Creating a bitmap from the downloaded inputstream

Bitmap b = BitmapFactory.decodeStream(iStream);

// Writing the bitmap to the temporary file as png file

b.compress(Bitmap.CompressFormat.PNG,100, fOutStream);

// Flush the FileOutputStream

fOutStream.flush();

//Close the FileOutputStream

fOutStream.close();

// Create a hashmap object to store image path and its position in the listview

HashMap hmBitmap = new HashMap();

// Storing the path to the temporary image file

hmBitmap.put("photo",tmpFile.getPath());

Log.d("photopah", tmpFile.getPath());

// Storing the position of the image in the listview

hmBitmap.put("position",position);

// Returning the HashMap object containing the image path and position

return hmBitmap;

}catch (Exception e) {

e.printStackTrace();

}

return null;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值