Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java getNodeValue()问题?_Java_Android_Xml - Fatal编程技术网

Java getNodeValue()问题?

Java getNodeValue()问题?,java,android,xml,Java,Android,Xml,我不知道为什么我的if语句没有被触发。我在日志中看到LoginStatus显示了成功 LoginStatus = nameElement.getFirstChild().getNodeValue().trim(); System.out.println("status = *" + LoginStatus + "*"); if(LoginStatus == "SUCCESS"){ String FILENAME = "UserData.xml"; FileOut

我不知道为什么我的if语句没有被触发。我在日志中看到LoginStatus显示了成功

LoginStatus = nameElement.getFirstChild().getNodeValue().trim();

System.out.println("status = *" + LoginStatus + "*");    

if(LoginStatus == "SUCCESS"){

     String FILENAME = "UserData.xml";
     FileOutputStream fos = ctx.openFileOutput(FILENAME, Context.MODE_PRIVATE);
     fos.write(response.getBytes());
     fos.close();
     System.out.println("File Created");

}

您没有正确比较
字符串。使用
equals
而不是相等运算符:

if("SUCCESS".equals(LoginStatus)){

p、 Java的惯例是变量以小写字母开头,因此
loginStatus

您没有正确比较
字符串。使用
equals
而不是相等运算符:

if("SUCCESS".equals(LoginStatus)){
p、 Java约定变量以小写字母开头,因此
loginStatus