comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TsvHelper.java @ 9559:ba0561906f81

Uinfo inundation duration workflow (vegetation zones, scenario), wms-config changed
author gernotbelger
date Wed, 24 Oct 2018 18:40:38 +0200
parents 787fc085459b
children 694062b1875a
comparison
equal deleted inserted replaced
9558:709a73badd48 9559:ba0561906f81
32 public TsvReaderException(final String message) { 32 public TsvReaderException(final String message) {
33 super(message); 33 super(message);
34 } 34 }
35 } 35 }
36 36
37 public static List<String[]> readTsv(final File inputFile, final int requiredLength) throws IOException, TsvReaderException { 37 public static List<String[]> readTsv(final File inputFile, final int maxLength) throws IOException, TsvReaderException {
38 38
39 final List<String[]> result = new ArrayList<>(); 39 final List<String[]> result = new ArrayList<>();
40 40
41 final byte[] BOM = new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF }; 41 final byte[] BOM = new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF };
42 final String bomChar = new String(BOM, "UTF-8"); 42 final String bomChar = new String(BOM, "UTF-8");
48 while ((line = reader.readNext()) != null) { 48 while ((line = reader.readNext()) != null) {
49 if (line == null || line[0].startsWith("#") || line[0].trim().equals("") || (line[0].startsWith(bomChar) && line[0].contains("#"))) { 49 if (line == null || line[0].startsWith("#") || line[0].trim().equals("") || (line[0].startsWith(bomChar) && line[0].contains("#"))) {
50 continue; 50 continue;
51 } 51 }
52 52
53 if (line.length != requiredLength) { 53 if (line.length > maxLength) {
54 reader.close(); 54 reader.close();
55 throw new TsvReaderException("Invalid number of Tokens; should be " + requiredLength + "!"); 55 throw new TsvReaderException("Invalid number of Tokens; should not be more than" + maxLength + "!");
56 } 56 }
57 result.add(line); 57 result.add(line);
58 } 58 }
59 } 59 }
60 return result; 60 return result;

http://dive4elements.wald.intevation.org