18 package org.turro.vcard.db;
20 import java.io.BufferedReader;
22 import java.io.FileInputStream;
23 import java.io.FileOutputStream;
24 import java.io.FilenameFilter;
25 import java.io.IOException;
26 import java.io.InputStreamReader;
27 import java.io.OutputStreamWriter;
28 import java.io.Writer;
29 import java.util.List;
30 import org.turro.csv.CSVList;
31 import org.turro.csv.CSVParser;
32 import org.turro.elephant.context.Application;
33 import org.turro.elephant.context.ElephantContext;
34 import org.turro.vcard.VCard;
42 public static final String
44 VCARD_EXPORT_FOLDER =
"/WEB-INF/vCard/out";
48 if(!root.exists()) root.mkdir();
54 if(!root.exists()) root.mkdir();
55 return root.listFiles(
new FilenameFilter() {
57 public boolean accept(File dir, String name) {
58 return name.endsWith(
".vcf");
65 if(!root.exists()) root.mkdir();
66 return root.listFiles(
new FilenameFilter() {
68 public boolean accept(File dir, String name) {
69 return name.endsWith(
".csv");
76 if(!root.exists()) root.mkdir();
77 return root.listFiles(
new FilenameFilter() {
79 public boolean accept(File dir, String name) {
80 return name.endsWith(
".csvrel");
89 BufferedReader in =
new BufferedReader(
90 new InputStreamReader(
new FileInputStream(f)));
100 public static CSVList
loadCSVs() throws IOException {
102 CSVList cl =
new CSVList();
103 for(File f : files) {
104 BufferedReader in =
new BufferedReader(
105 new InputStreamReader(
new FileInputStream(f)));
106 cl =
new CSVParser(in).getCSVs();
116 CSVList cl =
new CSVList();
117 for(File f : files) {
118 BufferedReader in =
new BufferedReader(
119 new InputStreamReader(
new FileInputStream(f)));
120 cl =
new CSVParser(in).getCSVs();
130 if(!root.exists()) root.mkdirs();
133 boolean append =
false;
134 for(
VCard vCard : list) {
135 Writer out =
new OutputStreamWriter(
new FileOutputStream(output, append));
136 out.write(vCard.getVCard());
static IContact getUser()
static String getRealPath(String path)
static final String VCARD_IMPORT_FOLDER
static File saveVCards(VCardList list)
static File getImportFolder()
static CSVList loadCSVRels()
static VCardList loadVCards()
static File[] getCSVRels()
static CSVList loadCSVs()
List< VCard > getVCards()