X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fparsers%2FAbookParser.java;h=b8e6e58e47c2187acf5fd80e8b3c046acacf6d33;hp=cb4f667119be22b0b8cf8713a1b7f439511c30a4;hb=59597d59aa262e31c2e1b7f66b4cb299f88ebd1b;hpb=e3fe983485916e0f3dbae73394f9dd8271623639 diff --git a/src/be/nikiroo/jvcard/parsers/AbookParser.java b/src/be/nikiroo/jvcard/parsers/AbookParser.java index cb4f667..b8e6e58 100644 --- a/src/be/nikiroo/jvcard/parsers/AbookParser.java +++ b/src/be/nikiroo/jvcard/parsers/AbookParser.java @@ -1,5 +1,6 @@ package be.nikiroo.jvcard.parsers; +import java.io.IOException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -132,4 +133,44 @@ public class AbookParser { return lines; } + + /** + * Write the given {@link Contact} in the {@link Appendable}. + * + * @param writer + * the {@link Appendable} + * @param contact + * the {@link Contact} to write + * @param startingBKey + * the starting BKey number (all the other will follow) or -1 for + * no BKey + * + * @throws IOException + * in case of IO error + */ + public static void write(Appendable writer, Contact contact, + int startingBKey) throws IOException { + for (String s : toStrings(contact, startingBKey)) { + writer.append(s); + writer.append('\n'); + } + } + + /** + * Write the given {@link Card} in the {@link Appendable}. + * + * @param writer + * the {@link Appendable} + * @param card + * the {@link Card} to write + * + * @throws IOException + * in case of IO error + */ + public static void write(Appendable writer, Card card) throws IOException { + for (String s : toStrings(card)) { + writer.append(s); + writer.append('\n'); + } + } }