开发工具 netbeans
模拟器能够进行通讯,但放在手机上不能,部分代码如下:
模拟器能够进行通讯,但放在手机上不能,部分代码如下:
StringBuffer sb = new StringBuffer();
conn = javax.microedition.io.Connector.open(url);
HttpConnection hconn = (HttpConnection) conn;
InputStream input = hconn.openInputStream();
java.io.InputStreamReader reader = new java.io.InputStreamReader(input);
while (true) {
char[] ch = new char[4];
int flag = reader.read(ch, 0, 4);
sb.append(ch);
if (flag == -1) {
break;
}
}
String msg = sb.toString();