import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.Image;
public class Connectioner implements Runnable {
private HttpConnection con;
private DataOutputStream os;
private final String URL="http://localhost:8080/exec/servlet/bbc.CreateImageServlet";
private Image image;
MainLet midplet;
/**
*
*/
public Connectioner(MainLet midplet) {
super();
this.midplet=midplet;
new Thread(this).start();
}
public void run(){
connHttp();
}
public synchronized void connHttp(){
while(true){
System.out.println("httpconn wait now");
if((midplet.getIsSending())){
System.out.println("search");
try{
con=(HttpConnection)Connector.open(URL);
con.setRequestMethod(HttpConnection.POST);
con.setRequestProperty("If-Modified-Since",
"29 Oct 1999 19:43:31 GMT");
con.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Configuration/CLDC-1.0");
con.setRequestProperty("Content-Language", "en-US");
os=new DataOutputStream(con.openOutputStream());
int[] rgbArg=new int[100*100];
midplet.getImage().getRGB(rgbArg,0,100,0,0,100,100);
for(int i=0;i<rgbArg.length;i++){
os.write(rgbArg[i]);
}
os.flush();
}catch(Exception e){
System.out.println("conn err");
e.printStackTrace();
}finally{
if(os!=null){
try{
os.close();
midplet.setIsSending(false);
midplet.setIsSend(true);
}catch(IOException ioe){};
}
}
midplet.setIsSending(false);
midplet.setIsSend(true);
}
try{
wait();
}catch(Exception e){
System.out.println("wait exception");
e.printStackTrace();
}
}
}
public synchronized void wakeUP(){
notifyAll();
}
}
http j2me 图片上传
4星 · 超过85%的资源 需积分: 3 63 浏览量
2009-07-14
14:24:49
上传
评论
收藏 4KB RAR 举报
小林2
- 粉丝: 7
- 资源: 93