public class VCardWriter extends StreamWriter implements java.io.Flushable
Writes VCard objects to a plain-text vCard data stream.
Example:
VCard vcard1 = ...
VCard vcard2 = ...
File file = new File("vcard.vcf");
VCardWriter vcardWriter = new VCardWriter(file, VCardVersion.V3_0);
vcardWriter.write(vcard1);
vcardWriter.write(vcard2);
vcardWriter.close();
Changing the line folding settings:
VCardWriter writer = new VCardWriter(...);
//disable line folding
writer.getRawWriter().getFoldedLineWriter().setLineLength(null);
//change line length
writer.getRawWriter().getFoldedLineWriter().setLineLength(50);
//change folded line indent string
writer.getRawWriter().getFoldedLineWriter().setIndent("\t");
//change newline character
writer.getRawWriter().getFoldedLineWriter().setNewline("**");
addProdId, index, versionStrict| Constructor and Description |
|---|
VCardWriter(java.io.File file,
boolean append,
VCardVersion targetVersion)
Creates a vCard writer.
|
VCardWriter(java.io.File file,
VCardVersion targetVersion)
Creates a vCard writer.
|
VCardWriter(java.io.OutputStream out,
VCardVersion targetVersion)
Creates a vCard writer.
|
VCardWriter(java.io.Writer writer,
VCardVersion targetVersion)
Creates a vCard writer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_write(VCard vcard,
java.util.List<VCardProperty> propertiesToAdd)
Writes a vCard to the stream.
|
void |
close()
Closes the underlying
Writer object. |
void |
flush()
Flushes the underlying
Writer object. |
VCardRawWriter |
getRawWriter()
Gets the writer that this object wraps.
|
VCardVersion |
getTargetVersion()
Gets the version that the vCards should adhere to.
|
boolean |
isCaretEncodingEnabled()
Gets whether the writer will apply circumflex accent encoding on
parameter values (disabled by default, only applies to 3.0 and 4.0
vCards).
|
void |
setCaretEncodingEnabled(boolean enable)
Sets whether the writer will apply circumflex accent encoding on
parameter values (disabled by default, only applies to 3.0 and 4.0
vCards).
|
void |
setTargetVersion(VCardVersion targetVersion)
Sets the version that the vCards should adhere to.
|
getScribeIndex, isAddProdId, isVersionStrict, registerScribe, setAddProdId, setScribeIndex, setVersionStrict, writepublic VCardWriter(java.io.OutputStream out,
VCardVersion targetVersion)
out - the output stream to write the vCard totargetVersion - the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)public VCardWriter(java.io.File file,
VCardVersion targetVersion)
throws java.io.IOException
file - the file to write the vCard totargetVersion - the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)java.io.IOException - if there's a problem opening the filepublic VCardWriter(java.io.File file,
boolean append,
VCardVersion targetVersion)
throws java.io.IOException
file - the file to write the vCard toappend - true to append to the end of the file, false to overwrite
ittargetVersion - the version that the vCards should conform to (if
set to "4.0", vCards will be written in UTF-8 encoding)java.io.IOException - if there's a problem opening the filepublic VCardWriter(java.io.Writer writer,
VCardVersion targetVersion)
writer - the writer to write the vCard totargetVersion - the version that the vCards should conform topublic VCardRawWriter getRawWriter()
public VCardVersion getTargetVersion()
getTargetVersion in class StreamWriterpublic void setTargetVersion(VCardVersion targetVersion)
targetVersion - the vCard versionpublic boolean isCaretEncodingEnabled()
Gets whether the writer will apply circumflex accent encoding on parameter values (disabled by default, only applies to 3.0 and 4.0 vCards). This escaping mechanism allows for newlines and double quotes to be included in parameter values.
When disabled, the writer will replace newlines with spaces and double quotes with single quotes.
VCardRawWriter.isCaretEncodingEnabled()public void setCaretEncodingEnabled(boolean enable)
Sets whether the writer will apply circumflex accent encoding on parameter values (disabled by default, only applies to 3.0 and 4.0 vCards). This escaping mechanism allows for newlines and double quotes to be included in parameter values.
When disabled, the writer will replace newlines with spaces and double quotes with single quotes.
enable - true to use circumflex accent encoding, false not toVCardRawWriter.setCaretEncodingEnabled(boolean)protected void _write(VCard vcard, java.util.List<VCardProperty> propertiesToAdd) throws java.io.IOException
StreamWriter_write in class StreamWritervcard - the vCard that is being writtenpropertiesToAdd - the properties to writejava.io.IOException - if there's a problem writing to the output streampublic void flush()
throws java.io.IOException
Writer object.flush in interface java.io.Flushablejava.io.IOException - if there's a problem flushing the writerpublic void close()
throws java.io.IOException
Writer object.close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if there's a problem closing the writerThis software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.