i have a program that is using string tokenizer to grab a char and a double value, but the file's data is stored like this c 500 c 21000 p 550 c 5950 c 3000 <------------------------- l 4000 p 4050 and so on........... where i have that arrow is where i need help how would i get string tokenizer to skip that line and IO.prinln("invalid entry") but then continue on grabing the next values such as l 4000 and p 4050... so far my code goes and prints out everthing up to c 3000 and then crashes...
Originally posted by Imran Bhutta: if u want to make like a chart ... you would use \t right?
Yes and no. It depends on the output device (terminal I assume here), but typically \t stops are set every eight columns. There's no guarantee, however. As well, what happens if one column will contain four to ten characters. That means sometimes the next column won't be straight from line to line.
If you're not too worried about that, yes \t will do what you want. If you need to be really anal about the table, you can make your own columns by outputing enough spaces to fill the column out. Here's a simple example: [ November 07, 2004: Message edited by: David Harkness ]
A more elegant way is to make a reusable utility somewhere:
column = Util.right(value, 8, "0");
That would mean right justify to a length of 8 padded with zeros. I have right, left and center methods I use to produce reports from arbitrary SQL queries. You can get clever ... to underline column headings:
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