googleのライブラリ

guava-libraries

Splitter.on(',')
.trimResults()
.omitEmptyStrings()
.split(" foo, ,bar, quux,")
--> ["foo", "bar", "quux"]


int count = Files.readLines(
new File("/path/to/file"),
Charsets.UTF_8, // remember that? :)
new LineProcessor<Integer>() {
int count = 0;
public boolean processLine(String line) {
count++;
}
public Integer getResult() { return count; }
});

google-collections