📄 gettext_form.java
字号:
package connectpacket;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import java.io.*;//要用到inputStream outputStream
import javax.microedition.io.*;//要用到httpconnection
public class GetText_Form extends Form implements CommandListener {
private GetText_MIDlet gtm;
private Command exitCommand;
private HttpConnection http_con=null;
private InputStream is=null;
private OutputStream os=null;
private DataOutputStream dos=null;
public GetText_Form(GetText_MIDlet gtm,String str_url)
{
super("GetText_Form");
this.gtm=gtm;
exitCommand=new Command("<Exit>",Command.EXIT,1);
this.addCommand(exitCommand);
this.setCommandListener(this);
try
{
if(http_con==null)
{
http_con=(HttpConnection)javax.microedition.io.Connector.open(str_url);
http_con.setRequestMethod(HttpConnection.GET);
http_con.setRequestProperty("if_Modified-Since", "5 April 2007 20:00:00 GMT");
http_con.setRequestProperty("User_Agent","Profile/MIDP-2.0 Configuration/CLDC+1.0");
}
if(is==null||os==null)
{
is=http_con.openInputStream();
os=http_con.openOutputStream();
}
//BufferedReader br=new BufferedReader(new InputStreamReader(is));//在j2me里面去除了bufferedreader类
InputStreamReader isr=new InputStreamReader(is);
int temp_length=is.available();//获取字节流的长度
char []buf=new char[temp_length];
isr.read(buf,0,buf.length);
this.append(String.valueOf(buf,0,buf.length));
//以下尝试想字节输出流中写东西...全高失败//
/*
os.write("123adsf".getBytes());
*/
/*int key_code=0;
ByteArrayOutputStream bos=new ByteArrayOutputStream();
while((key_code=is.read())!=-1)
{
bos.write(key_code);
bos.flush();
}
byte []buf_text=bos.toByteArray();
DataInputStream dis=new DataInputStream(new ByteArrayInputStream(buf_text));
this.append(dis.readUTF());
*/
/*
if(dos==null)
{
dos=http_con.openDataOutputStream();
dos.writeUTF("123adsf我很感动你门的热烈欢迎,同时感谢你们的热情招待,预祝你们成功");
}
*/
/*
OutputStreamWriter osr=new OutputStreamWriter(os);
osr.write("adsfads123001220");
*/
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void commandAction(Command c, Displayable arg1) {
// TODO 自动生成方法存根
if(c==exitCommand)
{
gtm.quitApp();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -