J2ME 中是否有与 FileInputStream
等价的东西?
最佳答案
您应该使用 JSR 75 中的 FileConnection。这是一个使用文件连接读取文件的简短示例:
public void showFile(String fileName) {
try {
FileConnection fc = (FileConnection)
Connector.open("file:///CFCard/" + fileName);
if(!fc.exists()) {
throw new IOException("File does not exist");
}
InputStream is = fc.openInputStream();
byte b[] = new byte[1024];
int length = is.read(b, 0, 1024);
System.out.println
("Content of "+fileName + ": "+ new String(b, 0, length));
} catch (Exception e) {
}
}
请看here了解更多信息。
关于java - 相当于J2ME中的FileInputStream?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6353453/