2 |
|
|
3 |
import java.io.BufferedReader; |
import java.io.BufferedReader; |
4 |
import java.io.IOException; |
import java.io.IOException; |
|
import java.io.InputStream; |
|
5 |
import java.io.InputStreamReader; |
import java.io.InputStreamReader; |
6 |
import java.nio.charset.Charset; |
import java.nio.charset.Charset; |
7 |
import java.util.List; |
import java.util.List; |
11 |
import com.google.common.base.Splitter; |
import com.google.common.base.Splitter; |
12 |
|
|
13 |
import dk.daoas.adressevedligehold.AddressSourceEntry.EntryType; |
import dk.daoas.adressevedligehold.AddressSourceEntry.EntryType; |
|
import dk.daoas.adressevedligehold.util.DeduplicateHelper; |
|
14 |
|
|
15 |
public class AddressSourceFD implements AddressSource { |
public class AddressSourceFD extends AbstractAddressSource { |
16 |
|
|
|
|
|
|
DeduplicateHelper<String> dirigeringsCache = new DeduplicateHelper<String>(); |
|
|
|
|
|
FileItem file; |
|
|
|
|
|
InputStream is; |
|
|
InputStreamReader isr; |
|
|
BufferedReader br; |
|
|
|
|
|
int lineCount = 0; |
|
17 |
|
|
18 |
String filenameFirst2; |
String filenameFirst2; |
19 |
|
|
20 |
public AddressSourceFD(FileItem file) throws Exception { |
public AddressSourceFD(FileItem file) throws Exception { |
21 |
this.file = file; |
super(file); |
22 |
|
|
23 |
filenameFirst2 = file.getName().substring(0, 2).toUpperCase(); |
filenameFirst2 = file.getName().substring(0, 2).toUpperCase(); |
24 |
} |
} |
|
|
|
|
@Override |
|
|
public String getFilename() { |
|
|
return file.getName(); |
|
|
} |
|
25 |
|
|
26 |
@Override |
@Override |
27 |
public void validate() throws IOException { |
public void validate() throws IOException { |
115 |
return "FD"; |
return "FD"; |
116 |
} |
} |
117 |
|
|
|
@Override //AutoCloseable |
|
|
public void close() throws Exception { |
|
|
System.out.println("Closing FD after lines " + lineCount); |
|
|
try { |
|
|
br.close(); |
|
|
isr.close(); |
|
|
is.close(); |
|
|
|
|
|
file.delete(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
System.out.println("Error on closing " + e.getMessage() ); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
118 |
} |
} |