a file is comma delimited what does this mean Why is a delim

a file is comma delimited, what does this mean? Why is a delimiter helpful when reading from a flat file of data?

Solution

The delimiters are useful while splitting the data in the file. The file is comma delimited means we can split the data in the file by using that comma. The delimiter is very helpful when reading the data from the flat files.

The following example will give you the best understanding of how the comma is useful when reading the data:

For example I have the employee.txt:

I would like to store the data in the as EID ENAME SALARY. Here I will use comma seperator.

employee.txt :

101,Jack,5000

102,Jane,6000

103,James,10000

104,Jordan,13000

when I am reading this file data :

FileReader fr = new FileReader(\"employee.txt\");

BufferedReader br = new BufferedReader(fr);

String line = null;

String eid,ename,salary;

while((line=br.readLine)!=null){

String a[] = line.split(\",\");//The delimiter comma is useful in better accessing the data

eid = a[0];ename= a[1];salary=a[2];

System.out.println(\"EID:\"+eid+\" ENAME:\"+ename+\" SALARY :\"+salary);

}

a file is comma delimited, what does this mean? Why is a delimiter helpful when reading from a flat file of data?SolutionThe delimiters are useful while splitti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site