File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Method to find reserved words Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Method to find reserved words" Watch "Method to find reserved words" New topic

Method to find reserved words

Tom Diamond
Ranch Hand

Joined: May 10, 2001
Posts: 98
Is there a method in the Java API that indicates wether a string given as parameter is a reserved word or not? (reserved word aka 'public', 'void', etc.).
omar khan
Ranch Hand

Joined: Feb 01, 2001
Posts: 183
I do not think it exists.
Never heard of.
Anyway to write one should be straightforward.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
I agree with Omar. The HashSet class seems ideal for this. Here's a list of keywords for you.

"I'm not back." - Bill Harding, Twister
Steve Loughran
Ranch Hand

Joined: Aug 06, 2002
Posts: 37
The code to do this is in apache tomcat and then in ant; it is there to rename JSP pages.

the code to compare this is simply

for performance, a hash table would be better.
I agree. Here's the link:
subject: Method to find reserved words