JavaME 文件连接 url
我想将数据保存到我的索尼爱立信 K750i。我知道手机实现了 FileConnection 版本 1.0。从中获取的根列表
FileSystemRegistry.listRoots();
返回名为“c:/”的单个元素。我想将 file.txt 保存在任何地方,但最好保存到附加的记忆棒上。不幸的是,它似乎不起作用。它抛出一个 IOException 且没有任何消息。我尝试在许多根目录上打开文件连接,例如 c:/、C:/、/、./、root1/、SDCard/、CFCard/、MemoryStick/ 以及其他一些根目录,但没有任何运气。
对于任何这些根,都会在该行之后抛出异常:
FileConnection filecon = (FileConnection) Connector.open("file:///MemoryStick/file.txt");
请问,我应该使用什么 URL?
I want to save data to my Sony Ericsson K750i. I know the phone implements FileConnection version 1.0. The list of roots taken from
FileSystemRegistry.listRoots();
returns single element named "c:/". I want to save a file.txt just about anywhere, but preferably to the memory stick attached. Unfortunately, it doesn't seem to work. It throws an IOException without any message. I tried opening the fileconnection on numerous roots like c:/, C:/, /, ./, root1/, SDCard/, CFCard/, MemoryStick/ and perhaps some more but without any luck.
The exception is thrown right after this line for any of those roots:
FileConnection filecon = (FileConnection) Connector.open("file:///MemoryStick/file.txt");
Please, what URL should i use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑您的问题是您试图在 MIDlet 不允许写入的位置写入文件。
我的猜测是,您可以阅读“c:/”足以弄清楚它的子文件夹是什么。您无法创建文件或子文件夹。
但是,浏览 c: 子文件夹,应该有一个位置可以在其中创建子文件夹和/或文件。
当然,所有这一切都假设您的 MIDlet 使用证书进行签名,该证书将其置于允许足够好的文件系统访问的安全域中。
I would suspect that your problem is that you are trying to write a file in a location your MIDlet isn't allowed to write to.
My guess is that you can read "c:/" just enough to figure out what its subfolders are. You can't create a file or a subfolder.
However, browse through c: subfolders and there should be a location somewhere where you can create a subfolder and/or a file.
Of course, all this assumes that your MIDlet is signed with a certificate that puts it in a security domain allowing good enough file system access.