I'm looking to parse the following string in java
<some lines here>
Key1:thingIWantToKnow
Key2:otherThing
Key3:bla
Key4:bla
Key5:bla
<(possibly) more lines here>
All lines end with a newline (\n) character. I'm looking to store the value pair once I find the key's I'm care about.
You can use StringUtils.split
http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringUtils.html
If you're looking for lines that contain 'Key' after that, use StringUtils.contains
Not the fastest, but certainly the most convenient, and null-safe too.
If a Map is what you want: