代码之家  ›  专栏  ›  技术社区  ›  haseman

在JDK中访问BlackBerry的“媒体”目录

  •  3
  • haseman  · 技术社区  · 15 年前

    尝试使用 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 权限集和我的应用程序已签名。

    1 回复  |  直到 12 年前
        1
  •  5
  •   Community CDub    7 年前

    BlackBerry上有两种文件系统——SD卡和Store。您必须使用其中一个,在路径中定义它。SD卡上存储视频、音乐等的标准目录是“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 - Getting Started with the FileConnection APIs
    RIM Forum - Some questions about FileConnection/JSR 75
    Use System.getProperty("fileconn.dir.memorycard") to check if SDCard available
    How to save & delete a Bitmap image in Blackberry Storm?

    推荐文章