using precompiled CommonPattern.TAB for split

pull/1/head
Michael Peter Christen 10 years ago
parent 1f5047b15f
commit de3e373913

@ -129,7 +129,7 @@ public class GeonamesLocation implements Locations {
if ( line.isEmpty() ) {
continue;
}
fields = line.split("\t");
fields = CommonPattern.TAB.split(line);
final long population = Long.parseLong(fields[14]);
if (minPopulation > 0 && population < minPopulation) continue;
final int geonameid = Integer.parseInt(fields[0]);

@ -52,5 +52,6 @@ public class CommonPattern {
public final static Pattern NEWLINE = Pattern.compile("\n");
public final static Pattern VERTICALBAR = Pattern.compile(Pattern.quote("|"));
public final static Pattern UNDERSCORE = Pattern.compile("_");
public final static Pattern TAB = Pattern.compile("\t");
}

@ -112,7 +112,7 @@ public class csvParser extends AbstractParser implements Parser {
// try comma, semicolon and tab; take that one that results with more columns
final String[] colc = CommonPattern.COMMA.split(row);
final String[] cols = CommonPattern.SEMICOLON.split(row);
final String[] colt = row.split("\t");
final String[] colt = CommonPattern.TAB.split(row);
if (colc.length >= cols.length && colc.length >= colt.length) separator = ",";
if (cols.length >= colc.length && cols.length >= colt.length) separator = ";";
if (colt.length >= cols.length && colt.length >= colc.length) separator = "\t";

Loading…
Cancel
Save