J2ME版HttpConnect
来源:互联网 发布:演技最好的电影 知乎 编辑:程序博客网 时间:2024/06/06 04:01
import java.io.DataInputStream;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.io.*;
public class HttpConnect extends MIDlet {
public HttpConnect() {
// TODO Auto-generated constructor stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException{
String URL = "http://192.168.0.114:8080/EngineService/sync?user=client";
try{
HttpConnection hpc = null;
DataInputStream dis = null;
boolean newline = false;
String content = "";
hpc = (HttpConnection)Connector.open(URL);
hpc.setRequestMethod(HttpConnection.GET);
dis = new DataInputStream(hpc.openInputStream());
int character;
while((character = dis.read())!= -1){
if((char)character=='//'){
newline=true;
continue;
}else{
if((char)character=='n'&&newline){
content += "/n";
newline = false;
}else if(newline){
content += "//"+(char)character;
newline = false;
}else{
content +=(char)character;
newline = false;
}
}
}
hpc.close();
hpc = null;
dis.close();
dis = null;
content = content.trim();
System.out.println(content);
}catch(Exception e){
System.out.println("Error:"+e);
}
}
}
- J2ME版HttpConnect
- HttpConnect
- HttpConnect与HttpClient基本用法
- J2ME版A*算法
- Asteroids的j2me版
- j2me版的Preferences
- j2me
- j2me
- J2ME
- J2ME
- j2me
- J2ME
- j2me
- j2me
- j2me
- J2ME
- j2me
- j2me
- BackGroundWorker解决 线程间操作无效: 从不是创建控件的线程访问它
- GetWindowRect与GetClientRect(转)
- Linux 中如何卸载已安装的软件(1)
- SLExtensions Commands的问题
- [API学习]操作驱动器挂载点说明
- J2ME版HttpConnect
- OPENSOCIAL AND SNS WEB
- Redhat5+xampp+zendstudio for eclipse 6.0.1配置调试
- 汉化DBCHART的预览窗口
- 学习
- 手机同步专家--基于SyncML协议同步通讯录的应用软件
- Heritrix的使用入门
- SQL注入式攻击代码分析
- 男人必吃的十种食物