package org.youza.test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class BuildvCard {
public vCard newvCard(){
vCard vcard = new vCard();
int count = 0;
do{
try {
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Vorname : ");
vcard.setVorname(console.readLine());
System.out.print("Nachname : ");
vcard.setNachname(console.readLine());
System.out.print("E-mail : ");
vcard.setE_mail(console.readLine());
System.out.print("Adresse : ");
vcard.setAddresse(console.readLine());
System.out.print("Organisation : ");
vcard.setOrganisation(console.readLine());
System.out.print("Telefon : ");
vcard.setTelefon(console.readLine());
count = 3;
} catch (Exception ex) {
System.out.println("Fehlereingabe");
count++;
if(count == 3)
{
System.out.println("Dreimal Falsch eingegeben damit bist du der Depp des Jahres servus!");
return null;
}
}
}while (count < 3);
return vcard;
}
public boolean schreiben(vCard vcard,String zielDatei) {
File file = new File(zielDatei);
FileWriter writer;
try {
writer = new FileWriter(file, true);
writer.write("BEGIN:VCARD");
writer.write(System.getProperty("line.separator"));
writer.write("VERSION:3.0");
writer.write(System.getProperty("line.separator"));
writer.write("N:"+vcard.getNachname()+";"+vcard.getVorname());
writer.write(System.getProperty("line.separator"));
writer.write("FN:"+vcard.getVorname()+" "+vcard.getNachname());
writer.write(System.getProperty("line.separator"));
writer.write("ORG:"+vcard.getOrganisation());
writer.write(System.getProperty("line.separator"));
writer.write("URL:"+vcard.getURL());
writer.write(System.getProperty("line.separator"));
writer.write("EMAIL;TYPE=INTERNET:"+vcard.getE_mail());
writer.write(System.getProperty("line.separator"));
writer.write("TEL;TYPE=voice,work,pref:"+vcard.getTelefon()+":");
writer.write(System.getProperty("line.separator"));
writer.write("ADR;TYPE=intl,work,postal,parcel:;;"+vcard.getAddresse()+":");
writer.write(System.getProperty("line.separator"));
writer.write("END:VCARD");
writer.close();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
}