This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "String validation" Watch "String validation" New topic
Author

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.
Thanks


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.


Bosun (SCJP, SCWCD)
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: String validation