尝试使用 JSR 75 访问保存在设备上的'/ home / video /'目录。使用Blackbery JDK 4.6.1。单行代码抛出' FileSystem IO Error '异常。像往常一样,这在极端情况下是无益的。

fconn = (FileConnection)Connector.open("file:///home/user/videos/"+name, Connector.READ);

有没有人试图这样做?我可以在我的jar中打开文件,但似乎无法访问媒体文件夹。我有 javax.microedition.io.Connector.file.read 权限集,我的appplication已签名。

有帮助吗?

解决方案

BlackBerry上有两种文件系统 - SDCard和商店。您必须使用其中一个,在路径中定义它。 SDCard上的标准目录,其中存储的视频,音乐等是“file:/// SDCard / BlackBerry”。

    String standardPath = "file:///SDCard/BlackBerry";
    String videoDir = System.getProperty("fileconn.dir.videos.name");
    String fileName = "video.txt";
    String path = standardPath+"/"+videoDir+"/"+fileName;
    String content = "";
    FileConnection fconn =  null;
    DataInputStream is = null;
    ByteVector bytes = new ByteVector();
    try {
        fconn = (FileConnection) Connector.open(path, Connector.READ);
        is = fconn.openDataInputStream();

        int c = is.read();
        while(-1 != c)
        {
            bytes.addElement((byte) (c));
            c = is.read();
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    content = new String(bytes.toArray());
    add(new RichTextField(content));

另见
SUN Dev Network - FileConnection API入门
RIM论坛 - 有关FileConnection / JSR 75的一些问题点击 使用System.getProperty(" fileconn.dir.memorycard")进行检查如果SDCard可用
如何保存&删除黑莓风暴中的位图图像?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top