GreennoisOn
Mitglied
Kriegst du die Funktion vielleicht irgendwie in Starting rein?
Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
package org.youza.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.youza.dto.vCard;
public class Starting {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
vCard vcard = new vCard();
newvCard(vcard);
if(vcard.writing("bla.vcf"))
System.out.println("passt!");
}
public static void newvCard(vCard 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!");
}
}
}while (count < 3);
}
}
package org.youza.dto;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class vCard {
private String Vorname;
private String Nachname;
private String Organisation;
private String URL;
private String E_mail;
private String Telefon;
private String Addresse;
public String getVorname() {
return Vorname;
}
public void setVorname(String vorname) {
Vorname = vorname;
}
public String getNachname() {
return Nachname;
}
public void setNachname(String nachname) {
Nachname = nachname;
}
public String getOrganisation() {
return Organisation;
}
public void setOrganisation(String organisation) {
Organisation = organisation;
}
public String getURL() {
return URL;
}
public void setURL(String uRL) {
URL = uRL;
}
public String getE_mail() {
return E_mail;
}
public void setE_mail(String e_mail) {
E_mail = e_mail;
}
public String getTelefon() {
return Telefon;
}
public void setTelefon(String telefon) {
Telefon = telefon;
}
public String getAddresse() {
return Addresse;
}
public void setAddresse(String addresse) {
Addresse = addresse;
}
public boolean writing(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:"+this.getNachname()+";"+this.getVorname());
writer.write(System.getProperty("line.separator"));
writer.write("FN:"+this.getVorname()+" "+this.getNachname());
writer.write(System.getProperty("line.separator"));
writer.write("ORG:"+this.getOrganisation());
writer.write(System.getProperty("line.separator"));
writer.write("URL:"+this.getURL());
writer.write(System.getProperty("line.separator"));
writer.write("EMAIL;TYPE=INTERNET:"+this.getE_mail());
writer.write(System.getProperty("line.separator"));
writer.write("TEL;TYPE=voice,work,pref:"+this.getTelefon()+":");
writer.write(System.getProperty("line.separator"));
writer.write("ADR;TYPE=intl,work,postal,parcel:;;"+this.getAddresse()+":");
writer.write(System.getProperty("line.separator"));
writer.write("END:VCARD");
writer.close();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
}