has*_*man 3 filesystems blackberry java-me jsr75 rim-4.6
尝试使用JSR 75访问保存在设备上"/ home/video /"目录下的媒体.使用Blackbery JDK 4.6.1.单行代码抛出' FileSystem IO Error'异常.像往常一样,这在极端情况下是无益的.
fconn = (FileConnection)Connector.open("file:///home/user/videos/"+name, Connector.READ);
Run Code Online (Sandbox Code Playgroud)
有没有人试过这样做?我可以在我的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));
Run Code Online (Sandbox Code Playgroud)
另请参阅
SUN Dev Network - FileConnection API入门
RIM论坛 - 有关FileConnection/JSR的一些问题75
使用System.getProperty("fileconn.dir.memorycard")检查SDCard是否可用
如何在Blackberry中保存和删除位图图像风暴?