Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String validation

 
Sandeep Lakshmipathy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic