public CsvWriter(final String file) { this.writer = IOUtils.getBufferedWriter(file); final String firstLine = CsvUtils.buildCsvLine( SEP, QUOTE, LOC_ID, STREET, NUMBER, ZIP_CODE, CITY, COUNTRY, STATUS, LONG, LAT, X, Y, QUALITY, QUALITY_CODE, MAPQUEST_STREET, MAPQUEST_ZIP_CODE, MAPQUEST_CITY, MAPQUEST_COUNTRY, MAPQUEST_STATUS); try { this.writer.write(firstLine); } catch (IOException e) { throw new UncheckedIOException(e); } }
private void write( final Address address, final MapquestResult.MapquestStatus status, final MapquestResult.Result result, final Status rejectCause) { // Why do I always have to go so dirty when writing files? final String[] fields = new String[18]; for (int i = 0; i < fields.length; i++) fields[i] = ""; if (address != null) { fields[0] = address.getId() != null ? address.getId() : ""; fields[1] = address.getStreet() != null ? address.getStreet() : ""; fields[2] = address.getNumber() != null ? address.getNumber() : ""; fields[3] = address.getZipcode() != null ? address.getZipcode() : ""; fields[4] = address.getMunicipality() != null ? address.getMunicipality() : ""; fields[5] = address.getCountry() != null ? address.getCountry() : ""; } if (rejectCause != null) { fields[6] = rejectCause.toString(); } if (result != null) { fields[7] = result.getLongitude().toString(); fields[8] = result.getLatitude().toString(); final Coord wgsCoord = new Coord(result.getLongitude(), result.getLatitude()); final Coord chCoord = new WGS84toCH1903LV03().transform(wgsCoord); fields[9] = "" + chCoord.getX(); fields[10] = "" + chCoord.getY(); fields[11] = result.getGeocodeQuality().toString(); fields[12] = result.getGeocodeQualityCode(); fields[13] = result.getStreet(); fields[14] = result.getZip(); fields[15] = result.getCity(); fields[16] = result.getCountry(); fields[17] = status.toString(); } final String line = CsvUtils.buildCsvLine(SEP, QUOTE, fields); try { this.writer.newLine(); this.writer.write(line); } catch (IOException e) { throw new UncheckedIOException(e); } }