在做JavaKe的项目。遇到一点问题,问问有经验的大家,打扰了
部分代码是:
public static boolean checkLogin(UserInfo user){
if(userDB.containsKey(user.getName())){
return ture;
}
System.out.println("Fail in Check!: "+user.getName());
return false;
}
作为查找服务端有没有该用户名,如果有,那么返回true;
private void processSocket(){
try{java.io.InputStream ins = client.getInputStream();
ous = client.getOutputStream();
BufferedReader brd = new BufferedReader(new InputStreamReader(ins));
sendMsg2Me("Welcome!Please type in your username: ");
String userName = brd.readLine();
sendMsg2Me("Please type in your password: ");
String pwd = brd.readLine();
user = new UserInfo();
user.setName(userName);
user.setPwd(pwd);
boolean loginState = DaoTools.checkLogin(user);
if(!loginState){
sendMsg2Me("Invalid Input!");
this.closeMe();
return;
}
else{
ChatTools.addClient(this);
String input = brd.readLine();
while(!"bye".equals(input)){
System.out.println("The Server Received: "+ input);
ChatTools.castMsg(this.user, input);
input = brd.readLine();
}}
}catch(Exception ef){ef.printStackTrace();}
ChatTools.castMsg(this.user, "I am OffLine.Bye!");
this.closeMe();
}错误log:Exception in thread "Thread-0" java.lang.Error: Unresolved compilation problem:
ture cannot be resolved to a variable at DaoTools.checkLogin(DaoTools.java:5)
at ServerThread.processSocket(ServerThread.java:39)
at ServerThread.run(ServerThread.java:19)
部分代码是:
public static boolean checkLogin(UserInfo user){
if(userDB.containsKey(user.getName())){
return ture;
}
System.out.println("Fail in Check!: "+user.getName());
return false;
}
作为查找服务端有没有该用户名,如果有,那么返回true;
private void processSocket(){
try{java.io.InputStream ins = client.getInputStream();
ous = client.getOutputStream();
BufferedReader brd = new BufferedReader(new InputStreamReader(ins));
sendMsg2Me("Welcome!Please type in your username: ");
String userName = brd.readLine();
sendMsg2Me("Please type in your password: ");
String pwd = brd.readLine();
user = new UserInfo();
user.setName(userName);
user.setPwd(pwd);
boolean loginState = DaoTools.checkLogin(user);
if(!loginState){
sendMsg2Me("Invalid Input!");
this.closeMe();
return;
}
else{
ChatTools.addClient(this);
String input = brd.readLine();
while(!"bye".equals(input)){
System.out.println("The Server Received: "+ input);
ChatTools.castMsg(this.user, input);
input = brd.readLine();
}}
}catch(Exception ef){ef.printStackTrace();}
ChatTools.castMsg(this.user, "I am OffLine.Bye!");
this.closeMe();
}错误log:Exception in thread "Thread-0" java.lang.Error: Unresolved compilation problem:
ture cannot be resolved to a variable at DaoTools.checkLogin(DaoTools.java:5)
at ServerThread.processSocket(ServerThread.java:39)
at ServerThread.run(ServerThread.java:19)
解决方案 »
- 【求助】XStream序列化对象到xml
- 在Java中,如何监听树的节点的鼠标双击事件?
- JFace使用SourceViewer,对其rule标尺进行绘图操作出现问题??急,本人在等待
- 索引超出范围
- 在eclipse 下面,为什么编写的C/S架构的软件编译后无法运行,是不是eclipse在编译C/S架构软件时需要一个插件呢?很急!!!!请教!!!
- 新手求教
- 急需!!!java native interface的应用者!!
- 请问这个bean什么地方错了?
- JAVA 的问题
- 继承中的Default constructor cannot handle exception type问题,求大神指点
- 命令提示:ticketssystem.java :23:找不到符号 符号:方法currentThread() 位置:类j
- JavaSwing排序动画源代码分享
true