日期:2014-05-20  浏览次数:20887 次

javaSE的登陆验证问题,我不知道错哪了。
没界面、没数据库,主要是用Socket和IO,main方法里调用,验证不成功,求指教

ClientCode

[code=Java]
package   shop_client;
import   java.io.BufferedOutputStream;
import   java.io.BufferedReader;
import   java.io.BufferedWriter;
import   java.io.IOException;
import   java.io.InputStreamReader;
import   java.io.ObjectInputStream;
import   java.io.ObjectOutputStream;
import   java.io.OutputStreamWriter;
import   java.net.Socket;
import   shop_entity.ShopUser;
import   shop_server.Socket_Server;
public   class   Socket_Client   {
Socket   s   =null;
String   flag   =null   ;  
ShopUser   su   =   null;

InputStreamReader   isr   =   null;
OutputStreamWriter   osw   =   null;

BufferedReader   br   =   null;
BufferedWriter   bw=   null;

BufferedOutputStream   bos   =   null;
ObjectInputStream   ois   =null;
ObjectOutputStream   oos   =null;
//初始化客户端socket信息
public   void   clientinit()
                  {
try{
s   =   new   Socket( "127.0.0.1 ",8099);
}catch(Exception     ex)
{
ex.printStackTrace();
}
}
//从键盘获得输入(Io流方式)
public   void   getKeyboard()
{
isr   =   new   InputStreamReader(System.in);
br   =   new   BufferedReader(isr);
try   {
flag   =   br.readLine();
}   catch   (IOException   e)   {
e.printStackTrace();
}
}
//登陆提示信息
public   void   showWelcome()
{
System.out.println( "=================== ");
System.out.println( "欢迎进入xxx超市系统 ");
System.out.println( "=================== ");
}
//登陆方法
public   void   userLogin()   throws   IOException
{
//接收控制台输入
isr   =   new   InputStreamReader(System.in);
br   =   new   BufferedReader(isr);
System.out.println( "请输入帐号: ");
String   name   =   br.readLine();
System.out.println( "请输入密码: ");
String   password   =   br.readLine();
//将控制台输入的帐号密码保存,并传入服务端
bos   =   new   BufferedOutputStream(s.getOutputStream());
oos   =   new   ObjectOutputStream(bos);
su   =   new   ShopUser(name,password);
oos.writeObject(su);
oos.flush();
}
//判断登陆
public   void   clientuserJudge()   throws   IOException
{
isr   =   new   InputStreamReader(s.getInputStream());
br   =   new   BufferedReader(isr);
String   loginInfo   =null;
Socket_Server   ss   =   new   Socket_Server();
while((loginInfo=br.readLine())!=null)                         [color=#FF0000]//****好像就是这里出错了****//[/color] {

if(loginInfo.equals(ss.showManager()))
{
System.out.println(loginInfo);
getKeyboard();
}else   if(loginInfo.equals(ss.showSale()))
{
System.out.println(loginInfo);
getKeyboard();
}else   if(loginInfo.equals( "登陆失败,请重新输入 "))
{
System.out.println(loginInfo);
userLogin();