📄 receivemessage.java
字号:
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ReceiveMessage extends Thread
{
private String message="";
private String ConnectionURL="";
private StreamConnection con=null;
private InputStream is=null;
private int data=0;
private List myList;
private Display display;
//private Command SendCommand;
public ReceiveMessage(String ConnectionURL,Display d,List tb)
{
this.ConnectionURL=ConnectionURL;
this.display=d;
this.myList=tb;
//SendCommand=new Command("发信息",Command.OK,1);
//myTextBox.addCommand(SendCommand);
//myTextBox.setCommandListener(this);
}
public void setConnectionURL(String ConnectionURL)
{
this.ConnectionURL=ConnectionURL;
}
public String getConnectionURL()
{
return ConnectionURL;
}
public void run()
{
String str="";
while(true)
{
System.out.println("ok");
try
{
con=(StreamConnection)Connector.open(ConnectionURL);
is=con.openInputStream();
data=0;
try
{
StringBuffer sb=new StringBuffer();
while((data=is.read())!=-1)
{
sb.append((char)data);
}
message="";
message=sb.toString();
myList.append(message,loadImage("/face1.png"));
display.setCurrent(myList);
System.out.println(message);
}
catch(IOException e){ System.out.println("no"); }
}catch(IOException e){ System.out.println("nothing"); }
}
}
public Image loadImage(String myImageURL)
{
Image myImage;
try
{
myImage=Image.createImage(myImageURL);
}
catch(Exception e)
{
myImage=null;
}
return myImage;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -