我试过"J2ME/Blackberry - how to read/write text file?"的例子。我只想读取功能,我想要读取的文件是以CSV格式作为放置在/res/test.txt中的.txt文件。“文件系统错误(1003)”打开BlackBerry文件连接
但我遇到了FileConnection问题。我得到以下错误:
File system error (1003)
任何建议或意见上一个更好的方法或如何我能得到这个工作?
public class FileDemo extends MainScreen {
public FileDemo() {
setTitle("My Page");
String str = readTextFile("file:///test.txt");
System.out.println("Contents of the file::::::: " + str);
}
public String readTextFile(String fName) {
String result = null;
FileConnection fconn = null;
DataInputStream is = null;
try {
fconn = (FileConnection) Connector.openInputStream(fName);
is = fconn.openDataInputStream();
byte[] data = IOUtilities.streamToBytes(is);
result = new String(data);
} catch (IOException e) {
System.out.println(e.getMessage());
} finally {
try {
if (null != is)
is.close();
if (null != fconn)
fconn.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
return result;
}
}
http://stackoverflow.com/questions/3267881/blackberry-read-a-text-file-packaged-in-the-project-faster 参考此链接。 –
尝试了上面的链接.. dint为我工作.. – Vikas