Lets take a stab at this one. I am assuming - NEVER a safe thing to do - that you are asking how to read from a file. Well Java has the concept of a stream and a stream is used to connect a source of data with a destination or a user of that data. Take a look here - http://docs.oracle.com/javase/tutorial/essential/io/ - for a pretty comprehensive primer.
I suggest you get rid of the Format object and use the printf method of System.out (a PrintStream) instead. You can find full details in the Formatter class and two descriptions which you can actually understand in the Java™ Tutorials: 12.
It makes your thread very hard to read, and it's actually bad coding practice (and one I've noticed you're guilty of in quite a lot of your posts).
I've broken yours up this time, but for future reference, please remember:
80 characters max.
(the SSCCE page actually recommends 62)
And that includes string literals AND comments AND long method calls.
Thanks.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
mike statham wrote:I have the following code but need to read from a file
You should be able to do it with the code you have, providing that your file data corresponds exactly with what your Scanner reads are requesting. In theory you also don't need the System.out.print... calls when you're reading from a file, but they don't do any specific harm.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here