📄 contactlistdemo.java
字号:
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class ContactListDemo extends MIDlet {
public ContactListDemo(){
super();
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
Form form=new Form("PIM支持测试");
form.append("支持PIM版本为:"+System.getProperty("microedition.pim.version")+"\n");
// Display.getDisplay(this).setCurrent(form);
Display.getDisplay(this).setCurrent(new showContactList(this));
}
public static String URL = "file:///root1/MMMy/"; // 模拟器根目录
/**保存文件到本地路径**/
public void saveFile(String name, byte[] data, String fileTypeName) throws Exception{
FileConnection fc = null;
String fileurl = null;
fileurl = URL + name + fileTypeName;
try {
fc = (FileConnection) Connector.open(fileurl, Connector.READ_WRITE);
if (!fc.exists()) {
fc.create();
DataOutputStream dos = fc.openDataOutputStream();
dos.write(data, 0, data.length);
dos.close();
fc.close();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
fc.close();
fc = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -