Created
January 6, 2014 17:26
-
-
Save pashields/8286238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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