sendmessage.java

来自「名称 移动QQ  一个手机上的QQ」· Java 代码 · 共 66 行

JAVA
66
字号
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.lcdui.*;

public class SendMessage 
{
   private String message="";
   private String ConnectionURL="";
   
   Alert alert;
   public SendMessage()
   {
     alert=new Alert("发送成功!");
     alert.setTimeout(Alert.FOREVER);
   }
   
   public void setMessage(String msg)
   {
     this.message=msg;
   }
   
   public String getMessage()
   {
     return message;
   }
   
   public void setConnectionURL(String str)
   {
     this.ConnectionURL=str;
   }
   
   public String getConnectionURL()
   {
     return ConnectionURL;
   }
   
   public void SendMsg()throws IOException
   {
       StreamConnection con=null;
       DataOutputStream os=null;
       StreamConnectionNotifier scn=(StreamConnectionNotifier)Connector.open(ConnectionURL);
       try
       {
         
         con=scn.acceptAndOpen();
         os=con.openDataOutputStream();
         String response=message;
	 message="";
	 os.writeUTF(response);
	 os.flush();
       }
       finally
       {
	 if(os!=null)
	 {
	    os.close();
	 }
	 if(con!=null)
	 {
	    con.close();
	 }
       } 
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?