Code example for Formatter

Methods: format

0
    public void write(Writer writer, PhonebookEntry entry) throws IOException {
 
        if (StringUtils.isEmpty(entry.getFirstName()) && StringUtils.isEmpty(entry.getLastName())) {
            return; 
        } 
        Formatter formatter = new Formatter(writer);
        writer.write("BEGIN:vCard\n");
        writer.write("VERSION:3.0\n");
        String firstName = StringUtils.defaultString(entry.getFirstName());
        String lastName = StringUtils.defaultString(entry.getLastName());
        formatter.format("N:%s;%s;;;\n", lastName, firstName);
        formatter.format("TEL;TYPE=%s:%s\n", m_telType, entry.getNumber());
        writer.write("END:vCard\n\n");
    } 
}