【发布时间】:2012-01-11 22:31:43
【问题描述】:
我愿意根据entry 制作一个将数据存储在文本文件中的简单应用程序,但我面临一个令人沮丧的异常。
这是我的代码:
private boolean saveFile(String fileName, String fileContent) {
DataOutputStream os = null;
FileConnection fconn = null;
try {
fconn = (FileConnection)Connector.open(fileName,Connector.READ_WRITE);
if (!fconn.exists())
fconn.create();
os=fconn.openDataOutputStream();
String myString=fileContent;
os.write(myString.getBytes());
os.close();
fconn.close();
} catch (IOException e) {
// TODO Auto-generated catch block
Dialog.alert(e.toString());
return false;
}
return true;
}
private String getFileName() {
return "file:///SDCard/BlackBerry/documents/text.dat";
}
这是我得到的例外:
net.rim.device.api.io.file.FileIOException: File system error
API 说明如下:
IOException - if the firewall disallows a connection that is not btspp or comm.
不知道有没有用。
我正在使用 BlackBerry JRE 4.6.1 和 BlackBerry 8900 Simulator。 希望大家帮帮我。
【问题讨论】:
-
哪一行抛出异常?写?
-
你在调试的时候发现
fileName的值是多少? -
您的要求是保存文本文件,但在 getFileName() 方法中您提供的是“filename.dat”。对于文本文件,它应该是“fileName.txt”。你得到了什么例外?
-
可以查看
FileIOException.getErrorCode()返回的值。 -
@Tamar
fconn = (FileConnection)Connector.open(fileName,Connector.READ_WRITE);正在抛出异常
标签: java blackberry blackberry-simulator