This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Zip code tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Zip code tables" Watch "Zip code tables" New topic
Author

Zip code tables

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hi. I have a question regarding validation of zip codes. Right now, we are switching from RPG to Java. In our RPG programs, we always had a zip code table we used to validate the zip codes that the user keyed. How on earth does this work in Java?? Could someone please help! (If you can't tell, I'm a newbie!) Thanks a million!
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Using exactly the same logic that the RPG program did. If the Zipcode table is in a database, do a jdbc call to look up the value. If it is a unsorted flat file, use and input stream to read through and compare each value(yuch) If it is sorted, You can use RandomAssess File and perform a binary search of the contents. (If it is unsorted, I recommend a one-time through to read it in and rewrite it as a sorted file.)

------------------
Hope This Helps
Carl Trusiak, SCJP2


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Zip code tables