Skip to content

Instantly share code, notes, and snippets.

@pashields
Created January 6, 2014 17:26
Show Gist options
  • Save pashields/8286238 to your computer and use it in GitHub Desktop.
Save pashields/8286238 to your computer and use it in GitHub Desktop.
private static final String[] = {"a", "b", "c"};
public String toDelimitedString(Model record) {
StringBuilder b = new StringBuilder();
// Add n-1 fields with delim
for (int i=0; i<fields.length-1; i++) { // With guava or commons colls could use iter here
b.append(record.get(fields[i]));
b.append(delim);
}
// Add last field with newline
b.append(record.get(fields[fields.length-1])).append('\n');
return b.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment