刚学J2ME编程,发现读取http连接老是数据读取不全(不超过256个字符),主要代码如下:
HttpConnection c = (HttpConnection)Connector.open( "http://localhost:8080/test.jsp ");
int rc = c.getResponseCode();
if (rc == HttpConnection.HTTP_OK) {
InputStream is = c.openInputStream();
java.io.ByteArrayOutputStream bao = new
ByteArrayOutputStream();
byte[] aB = new byte[20];
int sizeRead = is.read(aB);
while (sizeRead == 20) {
bao.write(aB);
sizeRead = is.read(aB);
//System.out.println( "%% ");
}
if (sizeRead > 0) {
bao.write(aB);
}
bao.flush();
String info = bao.toString().trim();
}
读取过来的数据,超过256个字符的,总被截掉了
------解决方案--------------------------------------------------------