I'm trying to read integers from a file (2 integer values separated by whitespace) that the program will use as variables. The following code works correctly. I was wondering, is there an easier method to read integer values from a file and then assign the values to specific variables?
That's pretty straightforward. If you're on JDK 1.4 or later, you can replace StringTokenizer with String.split() to tighten things up a bit. Test with some incorrect input, see what happens now and decide what you want to have happen:
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad: