This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Zip code tables" Watch "Zip code tables" New topic

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

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
I agree. Here's the link:
subject: Zip code tables
It's not a secret anymore!