dosend.java
上传用户:tie2000000
上传日期:2022-07-03
资源大小:4k
文件大小:1k
- package sendmsg;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStreamWriter;
- import java.net.*;
- public class dosend implements Runnable{
- String error="aqz";
- String info="";
- String u="";
- String msg="";
- int i=0;
- boolean stop=false;
- int success=1;
- public dosend(){
- }
- public synchronized void run(){
- stop=false;
- i++;
- System.out.println(i);
- while(!stop){
- try{
- System.out.println(""+i+"url="+u);
- System.out.println(stop);
- info="";
- URL url = new URL(u);
- URLConnection connection = url.openConnection();
- connection.setDoOutput(true);
- OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "8859_1");
- out.write("user=admin&code=admin&"+msg);
- out.flush();
- out.close();
- InputStream in=connection.getInputStream();
- info="n发送成功";
- stop=true;
- }catch(IOException e){
- try {
- wait(4000);
- } catch (InterruptedException e1) {
- }
- info=e.getMessage()+"n发送失败";
- System.out.println(e);
- }
- }
- System.out.println("break");
- stop=false;
- }
- public String getinfo(){
- return info;
- }
- public synchronized void setmsg(String gmsg){
- msg=gmsg;
- }
- public synchronized void settfip(String tfip){
- u=tfip;
- }
- public synchronized void quit(){
- stop=true;
- }
- }