/Users/lyon/j4p/src/addBk/addressBook/CSVMerge.java
|
1 package addBk.addressBook;
2
3 import futils.Futil;
4
5 import java.io.*;
6
7 public class CSVMerge {
8 static boolean isSwing = false;
9 //static boolean isSwing = true;
10
11 public CSVMerge(AddressBookDatabase abd) {
12
13 try {
14 BufferedReader br = getReader(
15 "select a CSV file");
16 for (String line = br.readLine(); line !=
17 null;
18 line = br.readLine())
19 abd.addRecord(
20 AddressBookRecord.getRecord(
21 line));
22
23 br.close();
24 } catch (FileNotFoundException e) {
25 } catch (IOException e) {
26 }
27
28 } // end constructor
29
30
31 public static File getFile(String prompt) {
32 if (isSwing)
33 return Futil.JGetReadFile(prompt);
34 return new File(
35 Futil.getReadFileName(prompt));
36 }
37
38 public static BufferedReader getReader(
39 String prompt)
40 throws FileNotFoundException {
41 return new BufferedReader(
42 new InputStreamReader(
43 new FileInputStream(
44 getFile(prompt))));
45 }
46
47
48 } // end CSVMerge
49
50