File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Hi check this code.It is not going in if condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hi check this code.It is not going in if condition" Watch "Hi check this code.It is not going in if condition" New topic
Author

Hi check this code.It is not going in if condition

Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
Hi
Please check this iit is not going in if condition.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
At what point?


cmbhatt
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
The code you have posted is working fine.. Check the input, Its case Sensitive..
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707


You are comparing the String reference (using ==) not the content equality
using (equals(Object).
Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
hi
I am reading from a file .whose contents are

Problem is it is reteiving the data from the file .But when it enters the while loop .It does nt compares the string in the if condition .I have tried using compareTo() and equals() also.But it is not comparing the string s.Also after reading 2 lines the reader goes to the third line and brings a blank space . which it should not show.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Did you use?



if you don't want use equals() do String t ="accId"; rather than
String t = new String("accId");
Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
thanks
Actually I did not trim the data coming from the file .It had space in it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hi check this code.It is not going in if condition