|
Opening and reading a file on the mobile device |
|
|
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){}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.