--- dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceDAO.java 2016/01/28 16:12:28 2868 +++ dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceDAO.java 2016/01/28 16:21:36 2869 @@ -1,9 +1,6 @@ package dk.daoas.adressevedligehold; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; import org.apache.commons.fileupload.FileItem; @@ -21,35 +18,7 @@ @Override public void validate() throws IOException { - try { - is = file.getInputStream(); - isr = new InputStreamReader(is, Charset.forName("ISO-8859-1") ); - br = new BufferedReader(isr); - - String line = br.readLine(); - if (line == null) { - throw new IOException("Can't read 1st line - is file empty?"); - } - - String[] parts = line.split(";"); - if (parts.length != 17) { - throw new IOException("Not enough fields in CSV file. Found " + parts.length + ", expected 17"); - } - - - - } catch (Exception e) { - try { - br.close(); - isr.close(); - is.close(); - } catch (Exception e2) { - System.out.println("Error cleaning up resources"); - } - - throw e; // Re-throw - - } + super.validateWithHeader(17, ';'); }