public static int getCommand(byte[] bytes){
String command=new String(bytes).trim();
return getCommand(command);
}
返回语句这么是写怎么解释?
String command=new String(bytes).trim();
return getCommand(command);
}
返回语句这么是写怎么解释?
public static int getCommand(String command){
int comm=0;
int start=command.indexOf('<');
if(start==0){
int end=command.indexOf('>');
command=command.substring(start+1,end);
if(command.equalsIgnoreCase("login")){
comm=1;
}
if(command.equalsIgnoreCase("list")){
comm=2;
}
if(command.equalsIgnoreCase("get")){
comm=3;
}
if(command.equalsIgnoreCase("help")){
comm=4;
}
if(command.equalsIgnoreCase("quit")){
comm=10;
}
if(command.equalsIgnoreCase("ok")){
comm=101;
}
}
return comm;
}
}
第一个方法返回的什么
至于方法里的处理,就是为了严谨吧。