Generic Connection Framework of javax.microedition.io package can be used to open a file on the mobile device.

The code below shows how to open a file and read from it using generic connection framework:

 try
{
  InputConnection fc = (FileConnection)Connector.open(
    "file://hello.txt");

  InputStream fis = fc.openInputStream();
  DataInputStream fdi = new DataInputStream(fis);

  int ch;
  String str = new String();

  while ( (ch = fdi.read()) != -1) 
  {
    str+=((char)ch);
  }

  fdi.close();
  fis.close();
  fc.close();
}
catch(IOException e){}