try {
FileConnection fc = (FileConnection) Connector.open("file:////T-Flash card/getfromserver.jpg");
if (!fc.exists()) {
fc.create();
} else {
fc.truncate(0);
}
OutputStream os = fc.openOutputStream();
os.write(b);
os.close();
fc.close();
os = null;
fc = null;
} catch (IOException e) {
e.printStackTrace();
// addStr("写文件出现异常" + e.toString());
}
}
private void read(String path) {
try {
FileConnection fc = (FileConnection) Connector.open("file:////T-Flash card/getfromserver.jpg");
if (!fc.exists()) {
// addStr("文件不存在");
return;
}
InputStream is = fc.openInputStream();
b = new byte[(int) fc.fileSize()];
is.read(b);
is.close();
is = null;
// addStr("文件内容:");
// addStr(new String(b));
fc.close();
fc = null;
// addStr("读文件完毕");
} catch (IOException e) {
l.setTitle("异常3:" + e.toString());
e.printStackTrace();
// addStr("读文件出现异常" + e.toString());
}
}