X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fresources%2FBundles.java;h=ef6e0d750ec2e9b80f518d3f756eab04787e114c;hb=47d06cf312c7f7a86b5861bb9a762c8856c4f58e;hp=00cd58ad23ad95c1cf1d126793c6d778e8203570;hpb=e119a1c1a924998b9315e46c96b1c750aab1deb9;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/resources/Bundles.java b/src/be/nikiroo/jvcard/resources/Bundles.java index 00cd58a..ef6e0d7 100644 --- a/src/be/nikiroo/jvcard/resources/Bundles.java +++ b/src/be/nikiroo/jvcard/resources/Bundles.java @@ -313,10 +313,36 @@ public class Bundles { * in case of IO error */ protected void writeValue(Writer writer, E id) throws IOException { - writer.write(id.name()); + writeValue(writer, id.name(), getString(id)); + } + + /** + * Write the given data to the config file, i.e., + * "MY_ID = my_curent_value" followed by a new line + * + * @param writer + * the {@link Writer} to write into + * @param id + * the id to write + * @param value + * the id's value + * + * @throws IOException + * in case of IO error + */ + protected void writeValue(Writer writer, String id, String value) + throws IOException { + writer.write(id); writer.write(" = "); - writer.write(getString(id)); - writer.write("\n"); + + String[] lines = value.replaceAll("\\\t", "\\\\\\t").split("\n"); + for (int i = 0; i < lines.length; i++) { + writer.write(lines[i]); + if (i < lines.length - 1) { + writer.write("\\n\\"); + } + writer.write("\n"); + } } /**