Reputation: 11
I have a text file like
vinoth 5001 chennai programmer
ramesh 7755 madurai tester
suresh 7452 namakal designer
salim 4652 salem programmer
I want to find with their designation but want to save their other details in an array. how can i do that? any suggestions
Upvotes: 1
Views: 398
Reputation: 40985
Read each line using buffered reader and then do that:
HashMap<String, String> values = new HashMap<String, String>;
// read the line here
String line = ...;
String strings[] = line.split(" ");
String designation = strings[3];
values.put(strings[0], strings[1], strings[2]);
Upvotes: 1
Reputation: 25613
String.split
to split the different informations into an arrayMap
whose key would be the username vinoth
and values would be the array you just received from String.split
Upvotes: 1
Reputation: 168815
String.substring(start, end)
to get the relevant part of the line.trim()
on it.Upvotes: 1