毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> java技术 >> 正文

ERROR:javax.microedition.io.ConnectionNotFoundException: TCP openExecution completed

更新时间:2012-7-3:  来源:毕业论文

就是自己练习一个很简单的获取一个网络上文本数据应用,获取后,显示在TextBox上,不知道为什么显示空白。麻烦大家看下哪里有问题。[code=Java][/code]public class weather extends MIDlet {
  private TextBox textbox;
public weather() throws IOException {
  super();
  String info = "";
  String preWeather = "";
  final String TITLE = "短期预报";
  DataInputStream in = null;
  HttpConnection wConnection = null;
  String URL = "http-://www-hzqx-com/gzhfw/dqyb.asp";
  try {
  wConnection = (HttpConnection)Connector.open(URL);
  wConnection.setRequestMethod(HttpConnection.GET);
  in = new DataInputStream(wConnection.openInputStream());
  int character;
while((character = in.read())!= -1)
  {  
  info += (char)character;
  }
  }catch (IOException e) {
  System.out.print("ERROR:" + e);
  }
finally
  {
  if (wConnection != null){
  wConnection.close();
  wConnection = null;
  }
  if (in != null){
  in.close();
  }
  }
  info = (unicodeTogb2312(info)).trim();
  preWeather = GetWeatherInfomation(info);
  textbox = new TextBox(TITLE,preWeather,20,0);
   
}

public static String unicodeTogb2312(String s){
  if(s == null){return "";}
  if(s.equals("")){return s;}
  try{
  return new String(s.getBytes("ISO8859_1"),"gb2312");
  }catch(Exception e){
  return s;
  }
  }
public static String GetWeatherInfomation(String str){
  String preWeather = "";
  String td = "今";
  String end = "更";
  int startNum;
  int endNum;
  startNum = str.indexOf(td);
  endNum = str.indexOf(end);
  if (startNum == -1){
  preWeather = "获取失败";
  return preWeather;
  }
  else {
  preWeather = str.substring(startNum, endNum);
  return preWeather;
  }
  }

不知道哪里出问题了。显示"获取失败",没内容。电脑可以上网。
Eclipse里关掉模拟器似乎有这么一句ERROR显示:ERROR:javax.microedition.io.ConnectionNotFoundException: TCP openExecution completed
 
tcp open应该是电脑的网络问题吧

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。