public boolean fileRead(String path, byte[] data ) {
Connection conn = null;
InputStream is = null;
try {
conn = Connector.open(path, Connector.READ);
FileConnection fc = (FileConnection)conn;
if (!fc.exists())
fc.create();
else
fc.truncate(0);
is = fc.openInputStream();
if (is.available() !=0)
is.read(data);
return true;
}
catch (Exception ie) {
return false;
}
finally {
try {
if (conn != null)
conn.close();
if (is != null)
is.close();
is.reset();
destroyApp(true);
notifyDestroyed();
} catch (Exception ioerr) {
return false;
}
}
}
Add a code snippet to your website: www.paste.org