Can we separate the List of only names from the data from file system as
Name Age Sex Address
dani 21 Male US
ron 34 Male NY
stella 23 Female NY
steave 43 Male US
[End]
I have tried to set the Delimiters as’\t’ in above data while inserting into file.
I tried
try
{
fin = openFileInput("FileSystemDatabase.dat");
isr = new InputStreamReader(fin);
br = new BufferedReader(new InputStreamReader(fin));
while ((line = br.readLine()) != null)
{
if (line.equals("\rName\tAge\tSex\tAddress\n"))
break;
}
Pattern p = Pattern.compile("\r\n\\d\t");
while ((line = br.readLine()) != null)
{
if (line.equals("[End]"))
break;
Matcher m = p.matcher(line);
if (m.matches())
{
text =m.group(1);
tv=new TextView(this);
tv.setText(text);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
But i am not getting the correct result to get correct List.Is there is any simple way to get it?
Please help me..
Try this.. You will get only the names:
Output:
06-28 11:30:08.009: E/String(3713): dani 21 Male US
06-28 11:30:08.009: E/Name(3713): dani
06-28 11:30:08.009: E/String(3713): ron 34 Male NY
06-28 11:30:08.009: E/Name(3713): ron
06-28 11:30:08.009: E/String(3713): stella 23 Female NY
06-28 11:30:08.009: E/Name(3713): stella
06-28 11:30:08.009: E/String(3713): steave 43 Male US
06-28 11:30:08.009: E/Name(3713): steave