Skip to content

Commit 2b7ff68

Browse files
committed
Update XmlMapper.java
1 parent 48fdec9 commit 2b7ff68

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/java/com/fasterxml/jackson/dataformat/xml/XmlMapper.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,25 @@ public void writeValue(File resultFile, Object value, String encoding)
439439
_writeValueAndClose(createGenerator(resultFile, encoding), value);
440440
}
441441

442+
/**
443+
* Method that can be used to serialize any Java value as
444+
* JSON output, using output stream provided (using encoding
445+
* {@link JsonEncoding#UTF8}).
446+
*<p>
447+
* Note: method does not close the underlying stream explicitly
448+
* here; however, {@link JsonFactory} this mapper uses may choose
449+
* to close the stream depending on its settings (by default,
450+
* it will try to close it when {@link JsonGenerator} we construct
451+
* is closed).
452+
*
453+
* @since 2.16
454+
*/
455+
public void writeValue(OutputStream out, Object value, String encoding)
456+
throws IOException, StreamWriteException, DatabindException
457+
{
458+
_writeValueAndClose(createGenerator(out, encoding), value);
459+
}
460+
442461
private JsonGenerator createGenerator(OutputStream out, String encoding) throws IOException {
443462
this._assertNotNull("out", out);
444463
JsonGenerator g = ((XmlFactory) _jsonFactory).createGenerator(out, encoding);

0 commit comments

Comments
 (0)