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 How to Check for Null or Empty Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to Check for Null or Empty Value" Watch "How to Check for Null or Empty Value" New topic
Author

How to Check for Null or Empty Value

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
I am using the following code section I to try and check for an empty or null value but it never is empty even though the string I send to it is blank.

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

You can check for null using if(myRef == null) or if (myRef != null).

However, a "blank" or empty String ("") is not null. It's a String with a length of zero. You can check this using myString.length(), after you verify that the reference is not null.

[ August 30, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
Thanks, for the help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Check for Null or Empty Value