接收到Handler传递出String类型数据后与原始String类型数据.equals()不相等的问题
服务器端代码:
public void xxx(){
try{
//一些操作
...............................................
[color=#00FF00] this.outString("钢厂关联物资成功!"); //给客户端的相应数据[/color]
}catch(Exception e){
e.printStackTrace();
}
}
客户端代码:
try {
new Thread() {
public void run() {
// 向服务器提交数据
String reponseStr0 = HttpUtil.formUpload(
Constant.URL_MAIN + "xxx.do",
text, pic);
System.out.println(TAG + "-->上传数据后服务器响应数据为: "
+ reponseStr0);
// 将服务器响应回传给UI线程
Message message = Message.obtain();
message.what = 4;
message.obj = reponseStr0.toString();
handler.sendMessage(message);
System.out.println("message 4 -->" + reponseStr0
+ " is already send to handler");
}
}.start();
} catch (Exception e) {
e.printStackTrace();
}
Handler handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 4: {
String temp = (String) msg.obj;
String ori =new String( "钢厂关联物资成功!");
System.out.println("temp-->" + temp);
System.out.println("ori-->" + ori);
if (temp.equals(ori)) {
System.out.println("temp 和 ori 相等!");
m_pDialog.setMessage("上传成功!");
// 需要关闭这个提示的时候:
m_pDialog.dismiss();
finish();
} else {
System.out.println("temp 和 ori 不相等!");
m_pDialog.setMessage("上传失败!");
// 需要关闭这个提示的时候:
m_pDialog.dismiss();
}
}
break;
default:
break;
}
super.handleMessage(msg);
}
};
然后就一直提示二者不相等,但其实打印出来二者是相等的,请问这是什么问题,烦请路过的各位大神指点一二,小弟感激不尽!
如下是日志打印内容:
08-15 08:36:22.548: I/System.out(5071): temp-->钢厂关联物资成功!
08-15 08:36:22.548: I/System.out(5071): ori-->钢厂关联物资成功!
08-15 08:36:22.548: I/System.out(5071): temp 和 ori 不相等!