srikanta saha
srikanta saha

Reputation: 11

How do I read the third value from each line of a file in Java?

I'm handling a loan monitoring system project, and in this project customer details will be saved in a text file with a row for each customer like:

sri chennai 10000 asda casca   08989

From the customer details a project officer needs only the third field (that is amount of loan) and he uses that to calculate installment rate of interest which will be written to another file.

How can I extract just the needed information from the file?

Upvotes: 0

Views: 174

Answers (3)

Garbage
Garbage

Reputation: 1520

You can use StringTokenizer as well.

Upvotes: 0

Aaron Digulla
Aaron Digulla

Reputation: 328614

Use BufferedReader to read the file line by line. Use String.split() or String.substring() to locate fields. Write the result to a new file using the IO classes.

Upvotes: 1

GuruKulki
GuruKulki

Reputation: 26418

Read the file line by line and get the substring between second and the third space.

Please work on explaining the question properly.

Upvotes: 2

Related Questions