您应该使用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) {
}
}
Run Code Online (Sandbox Code Playgroud)
请看这里了解更多信息.
| 归档时间: |
|
| 查看次数: |
887 次 |
| 最近记录: |