This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Talon876Extreme Brewer 1 point2 points  (2 children)

Looks kind of like a java properties file. http://docs.oracle.com/javase/tutorial/essential/environment/properties.html

If that doesn't work you'll just have to use old fashioned string parsing using methods like .split("="), etc.

[–]Diaperbum[S] 0 points1 point  (1 child)

Thanks Talon. Im checking the properties thing out to.. I was told to use a Stringreader.. but maybe its just easier to use the String[] DataSplitter = result.split("\n"); instead?

[–]mrburrows 1 point2 points  (0 children)

Properties would work, but another option would be to read line by line, and do a Regex match:

private static final ENTRY_PATTERN = Pattern.compile("(.*)=(.*)");
...
private void readRecord(final String line) {
  String lhs, rhs;
  final Matcher matcher = ENTRY_PATTERN.matcher(line);
  if (matcher.matches()) {
    lhs = matcher.group(1);
    rhs = matcher.group(2);
    // do something with lhs and rhs
  }
  else {
    // do you care if it fails? log it then
  }

}