A tab delimited file has a simple structure. Every line (record) has the same number of fields. Each field is separated by the tab character.
Each line of the file cia.txt
represents a country. Each has five fields:
- name
- region
- area
- population
- gdp
A sample from cia.txt:
Lithuania Europe 65200 3596617 45230000000 Luxembourg Europe 2586 468571 27270000000
1. [ Java ] Splitting the fields
We split the line on the tab character and copy each field into a variable with an appropriate name and an appropriate type.
In a tab delimited file we need to convert each field from a String to the appropriate type if required.
This program prints the name for every country with a large population.