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
String.substring(start, end)
to get the relevant part of the line. trim()
on it. String.split
to split the different informations into an array Map
whose key would be the username vinoth
and values would be the array you just received from String.split
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]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.