📄 test_midlet.java
字号:
/*
* Created on Aug 8, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.Class;
import java.io.InputStreamReader;
/**
* @author blrc
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Test_Midlet extends MIDlet{
final int MAX_LENGTH = 2046;
byte[] buf = new byte[MAX_LENGTH];
protected Display display;
Form form;
InputStream is;
String str;
static Class obj;
public Test_Midlet()
{
form = new Form("Test_CN");
display = Display.getDisplay(this);
}
protected void startApp() throws MIDletStateChangeException
{
InputStream is = getClass().getResourceAsStream("/help/settings.txt");
InputStreamReader dis = new InputStreamReader(is);
StringBuffer sb=new StringBuffer();
try
{
int ch = 0;
while((ch= dis.read()) != -1)
{
if(ch != 0)
{
sb.append((char)ch);
}
}
//dis.close();
is.close();
}
catch (Exception e)
{
e.printStackTrace();
}
str = new String(sb);
sb.delete(0,sb.length());
form.append(str);
form.append("The string length:" + str.length());
/*
try
{
// obj = Class.forName("Test_Midlet");
is = getClass().getResourceAsStream("/settings.txt");
if(is != null){
System.out.println("1");
int count = is.read(buf, 0, is.available());
str = new String(buf,0,count);
form.append(str);
form.append("The string length:" + str.length());
}
else System.out.println("can not find file!");
}
catch (Exception e)
{
e.printStackTrace();
}
*/
//str = "\u00d0\u00a4\u00d4\u00c6\u00c5\u00f4";
//str = "\u00d0\u00a4";
//try {
// String s = new String(str.getBytes("iso-8859-1"),"gb2312");
// System.out.println(s};
//} catch (UnsupportedEncodingException e) {
/// // TODO Auto-generated catch block
// e.printStackTrace();
//}
//form.append(str);
display.setCurrent(form);
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
*/
protected void destroyApp(boolean arg0){
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -