Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java @ 1477:6e694603cde1
Improved the CSVExportService to ignore lines that begin with a '#' character.
flys-client/trunk@3522 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 22 Dec 2011 09:28:22 +0000 |
parents | bc06a671ef60 |
children | 1f2f08211a5f |
comparison
equal
deleted
inserted
replaced
1476:edf18a9dfd8b | 1477:6e694603cde1 |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import java.util.ArrayList; | |
3 import java.util.List; | 4 import java.util.List; |
4 | 5 |
5 import java.io.Reader; | 6 import java.io.Reader; |
6 import java.io.InputStream; | 7 import java.io.InputStream; |
7 import java.io.InputStreamReader; | 8 import java.io.InputStreamReader; |
62 ec.addAttr(action, "name", name, true); | 63 ec.addAttr(action, "name", name, true); |
63 | 64 |
64 requestDoc.appendChild(action); | 65 requestDoc.appendChild(action); |
65 | 66 |
66 HttpClient client = new HttpClientImpl(url, locale); | 67 HttpClient client = new HttpClientImpl(url, locale); |
68 | |
67 try { | 69 try { |
68 InputStream in = client.collectionOut(requestDoc, uuid, "export"); | 70 InputStream in = client.collectionOut(requestDoc, uuid, "export"); |
69 Reader reader = new InputStreamReader (in, "UTF-8"); | 71 Reader reader = new InputStreamReader (in, "UTF-8"); |
70 CSVReader csvReader = new CSVReader (reader); | 72 CSVReader csvReader = new CSVReader (reader); |
71 | 73 |
72 return (List<String[]>) csvReader.readAll (); | 74 List<String[]> lines = new ArrayList<String[]>(); |
75 String[] line = null; | |
76 | |
77 while ((line = csvReader.readNext()) != null) { | |
78 if (line != null && line.length > 0) { | |
79 if (!line[0].startsWith("#")) { | |
80 lines.add(line); | |
81 } | |
82 } | |
83 } | |
84 | |
85 return lines; | |
73 } | 86 } |
74 catch (IOException ce) { | 87 catch (IOException ce) { |
75 logger.error(ce.getLocalizedMessage()); | 88 logger.error(ce.getLocalizedMessage()); |
76 } | 89 } |
77 | 90 |