當我運行這個程序時,我輸入用戶名爲"dcole"
和密碼"test"
,但是當我輸入它們時,他們返回"ÿûÿû ÿûÿû'ÿýÿûÿýdcole"
和"ÿþÿþ ÿþÿþ'ÿütest"
。下面的代碼:Java BufferedReader返回奇怪的字符
clientoutput.write("Please enter your username: ".getBytes("UTF-8"));
clientoutput.flush();
String username = clientinput.readLine();
out("Client " + clientip + " logged in as " + username);
String askforpass = "Please enter the password for " + username + ": ";
clientoutput.write(askforpass.getBytes());
clientoutput.flush();
String password = clientinput.readLine();
out(password);
控制檯:
Client connected with the IP /127.0.0.1
Client /127.0.0.1 logged in as ÿûÿû ÿûÿû'ÿýÿûÿýdcole ÿþÿþ ÿþÿþ'ÿütest
你在哪裏創建'BufferedReader'? – Jeffrey 2012-04-07 03:45:08