.jad文件未在Blackberry中下载 [英] .jad file not downloading in Blackberry

查看:69
本文介绍了.jad文件未在Blackberry中下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误是:

java.io.IOException: Resource could not be found 
http://www.abc.com/ABC.cod:411 - Length Required.



当我按下下载按钮时,代码将执行&我在blackbarry中收到此错误.在Windows&诺基亚手机正在下载Jad文件&然后抛出错误的贾德不支持,这是可以的.

Blackbarry是RIM os mobile,为什么会引发错误,请帮助我.

我的开发代码是这样的:
此代码位于按钮单击事件中



When i press download button the code executes & i get this error in blackbarry. In windows & nokia mobile it is downloading jad file & then throw error jad is not support which is ok.

Blackbarry is RIM os mobile tht why this throws error plz help me for tht.

my develop code is like this:
this code is in button click event

mFileName = "ABC.jad";
mContentType = "text/vnd.sun.j2me.app-descriptor";


bool succ = ResponseFile(Page.Request, Page.Response, mContentType,
        mFileName, Server.MapPath("~/" + mFileName), 1024000);
if (!succ)
{
   Response.Write("Download Error");
}
Response.End();


此功能用于下载文件:


this function is used to download file:

public static bool ResponseFile(HttpRequest _Request, HttpResponse _Response,string _ContentType, string _fileName, string _fullPath, long _speed)
    {
        try
        {
            FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            BinaryReader br = new BinaryReader(myFile);
            try
            {
                _Response.AddHeader("Accept-Ranges", "bytes");
                _Response.Buffer = false;
                long fileLength = myFile.Length;
                long startBytes = 0;
                int pack = 10240; //10K bytes
                int sleep = (int)Math.Floor((double)(1000 * pack / _speed)) + 1;
                if (_Request.Headers["Range"] != null)
                {
                    _Response.StatusCode = 206;
                    string[] range = _Request.Headers["Range"].Split(new char[] { '=', '-' });
                    startBytes = Convert.ToInt64(range[1]);
                }
                _Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
                if (startBytes != 0)
                {
                    _Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength - 1, fileLength));
                }
                _Response.AddHeader("Connection", "Keep-Alive");
                _Response.ContentType = _ContentType;
                _Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_fileName, System.Text.Encoding.UTF8));
                br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
                int maxCount = (int)Math.Floor((double)((fileLength - startBytes) / pack)) + 1;
                for (int i = 0; i < maxCount; i++)
                {
                    if (_Response.IsClientConnected)
                    {
                        _Response.BinaryWrite(br.ReadBytes(pack));
                        Thread.Sleep(sleep);
                    }
                    else
                    {
                        i = maxCount;
                    }
                }
            }
            catch
            {
                return false;
            }
            finally
            {
                br.Close();
                myFile.Close();
            }
        }
        catch
        {
            return false;
        }
        return true;
    }


请Plz帮助我解决错误.


Plz help me in order to solve the error.

推荐答案

原来,此问题应标记为重新发布".
您在这里问过同样的问题: http://www.codeproject.com/answers/68661/How-can-download-jad-file-using-mobile-web-pages-i.aspx [
Origianlly this question should be marked as a Re-Post.
You had asked the same thing here: http://www.codeproject.com/answers/68661/How-can-download-jad-file-using-mobile-web-pages-i.aspx[^]
But, the point is you yourself has answered to it 3 times and made it look like 5 answers to it has already been provided. You should not use answer button as long as its not an answer. Just update the question with further comments.


Chetan,很抱歉,如果英语不是您的母语,但是当有人说不按答案"时,很难理解如果您不发布答案?另外,不要使用txt说话,这会让您看起来像个白痴.
Chetan, I''m sorry if English is not your first language, but how hard is it to understand when someone says ''do not push answer if you''re not posting an answer'' ? Also, don''t use txt speak, it makes you look like a moron.


上面的异常表明,鳕鱼文件中没有提到Length.
The exception above shows that the Length is not mentioned in the cod file.


这篇关于.jad文件未在Blackberry中下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆