/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceDAO.java
ViewVC logotype

Diff of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressSourceDAO.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2868 by torben, Thu Jan 28 16:12:28 2016 UTC revision 2869 by torben, Thu Jan 28 16:21:36 2016 UTC
# Line 1  Line 1 
1  package dk.daoas.adressevedligehold;  package dk.daoas.adressevedligehold;
2    
 import java.io.BufferedReader;  
3  import java.io.IOException;  import java.io.IOException;
 import java.io.InputStreamReader;  
 import java.nio.charset.Charset;  
4    
5  import org.apache.commons.fileupload.FileItem;  import org.apache.commons.fileupload.FileItem;
6    
# Line 21  public class AddressSourceDAO extends Ab Line 18  public class AddressSourceDAO extends Ab
18                    
19          @Override          @Override
20          public void validate() throws IOException {          public void validate() throws IOException {
21                  try {                  super.validateWithHeader(17, ';');
                         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  
                           
                 }  
22          }          }
23                    
24    

Legend:
Removed from v.2868  
changed lines
  Added in v.2869

  ViewVC Help
Powered by ViewVC 1.1.20