I have data in my text file in the following format
apple fruit
carrot vegetable
potato vegetable
I want to read this line by line and split at the first space and store it in a set or map or any similar collections of java. (key and value pairs)
example :-
"apple fruit"
should be stored in a map where the
key = apple
and
value = fruit
.