开发者

FileIOException: File already exists error on blackberry

i get thumbnail image using fileconnection.

I get image using thread constructor. I pass the url and get image.

If the two image url are same , i got exception "FileIOException: File already exists "

My code is here.,

FileConnection fConn = null;
try 
{
        String fileString = MD5.encodeStringMD5(url);
        fConn = (FileConnection) Connector.open(fileTempPath+fileString+".png");
        if(!fConn.exists())
        {
                fConn.create();
                GetImageFromURL(url,fConn,id);
        }
        else
        {
                 GetImageFromFolder(fConn, id);
        }
        fConn.close();
}
catch (Exception e) 
{
       System.out.println("------"+e);
}

If the urls are differ. No pr开发者_高级运维oblem occur. But if two or three url r same , Only one image only stored and load on screen. others same url not displaying.

After stored on device memory, its loadding all image.

The Exception throws in this line - "fConn.create();"


Before creating a new file, try to open a file with the same name/path. If it already exists remove it.


If file already exits then do like this:

if(!fConn.exists())
    {
            fConn.create();
            GetImageFromURL(url,fConn,id);
    }
    else
    {
             fConn.truncate();//it removes the data in that file;
             GetImageFromFolder(url,fConn, id);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜