This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I get the values of fileDirectory and mimeType from a List. The value of mimeType I receive is "text/xml". the first if-condition works fine, however the second if-condition doesn't work at all, and hence I'm not able to read the contents of the file.
The code looks simple, but I'm unable to figure out what the problem is.
Any help appreciated. Sara
String fileDirectory = list.get(0).toString(); String mimeType = list.get(1).toString(); // value is text/xml //System.out.println("mimeType is "+mimeType);
You should read up on the difference between the == operator and the equals() method. In general, the == operator will not behave the way you expect when comparing objects. Use the equals() method instead.