相当于J2ME中的FileInputStream?

Abh*_*hek 5 java fileinputstream java-me

FileInputStream在J2ME中有没有相同的东西?

Ale*_*exR 9

您应该使用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)

请看这里了解更多信息.