jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes String validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "String validation" Watch "String validation" New topic

String validation

Sandeep Lakshmipathy
Ranch Hand

Joined: Mar 05, 2002
Posts: 31
Dear Friends,
I wanted to know if there is some way of validating a string that the user has entered. I want to check at runtime if the string entered will not generate compilation errors. I do not want the dynamically generated class of mine which has this string in it to fail during compilation. Is there a method in some standard classes to do this. I am lost. Please help me on this.

Sandeep Lakshmipathy
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You want to check at runtime if the string will not generate compile errors??? I don't understand. Heck! If the string generates compile errors, you will not even get to runtime.
It all depends on what you mean by validation. You can check a string for null, spaces, or even check for a specific length. Any good textbook should get you what you need.

So much trouble in the world -- Bob Marley
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
I like to validate strings using regular expressions. Java 1.4 has them built in or you can get the ORO matcher from java.apache.org.
I agree. Here's the link: http://aspose.com/file-tools
subject: String validation
It's not a secret anymore!