I've massaged my file input and now have a List<String> where each line has 4 fields separated by whitespace. I want to run a Scanner on it to parse each line. Can I do that?
More generally, I have a List<String> that has whitespace separated fields. I'd love to create a class defining each field, then have 1 glorious doohicky to parse a line into that object.
Each line has the format "int int char string"
Example: Line is "2 12 c doremi"
I'd love to make a:
class stuff {
int a;
int b;
char c;
String line;
};
And magically slurp a line into a stuff. But I'm perfectly happy ignoring stuff and slurping each field of a line into it's variables.
I've actually just spent 3 hours relearning Java streams to get my massaged input List and am in a streams mindset.
I'm also scared at how much Java I've forgotten in the last 2-3 years.
More generally, I have a List<String> that has whitespace separated fields. I'd love to create a class defining each field, then have 1 glorious doohicky to parse a line into that object.
Each line has the format "int int char string"
Example: Line is "2 12 c doremi"
I'd love to make a:
class stuff {
int a;
int b;
char c;
String line;
};
And magically slurp a line into a stuff. But I'm perfectly happy ignoring stuff and slurping each field of a line into it's variables.
I've actually just spent 3 hours relearning Java streams to get my massaged input List and am in a streams mindset.
I'm also scared at how much Java I've forgotten in the last 2-3 years.