尝试使用 JSR 75访问保存在设备上“/home/video/”目录下的媒体。使用黑莓 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
权限并且我的应用程序已签名。
最佳答案
BlackBerry 上有两种文件系统 - SDCard 和 store。您必须使用其中之一,在路径中定义它。 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 - 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?
关于blackberry - 在 JDK 中访问 Blackberry 的 'Media' 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/826892/