求救,传真机接口的网络通讯问题

hellostory 2009-08-25 05:31:24
通过调用getTips()方法向服务器发送命令并返回处理结果,第一次调用时可以正确返回结果,但第二次再调用(发送不同的命令消息字符串strCmd)时,运行到“strAcceptMsg = is.readLine().trim();”就发生错误:“Exception in thread "main" java.lang.NullPointerException”,为什么呢,求救

public ArrayList getTips(String strCmd){
messageList.clear(); //清空
try{
System.out.println("strCmd: "+ strCmd);
os.println(strCmd); //写入输出流
os.flush(); //刷新输出流,使Server马上收到该字符串

strAcceptMsg = is.readLine().trim(); //读第一条消息
while(!strAcceptMsg.equals(".") && !strAcceptMsg.equals("ERROR COMMAND")){
System.out.println("服务器消息:" + strAcceptMsg);//打印服务器返回消息
if(!strAcceptMsg.equals("OK faxinfo")){
messageList.add(strAcceptMsg);
}
strAcceptMsg = is.readLine().trim(); //读下一条消息
}
}catch(Exception e){
e.printStackTrace();
}
return messageList;
}
...全文
120 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
酒浪子 2009-08-25
  • 打赏
  • 举报
回复
学习!

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧