Here you can find the source of writeIfSet(final OutputStream outputStream, final String field, final String value)
Parameter | Description |
---|---|
field | a parameter |
value | a parameter |
static final void writeIfSet(final OutputStream outputStream, final String field, final String value) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.OutputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; public class Main { static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; /**/*from w w w .j a v a 2 s. c om*/ * @param field * @param value */ static final void writeIfSet(final OutputStream outputStream, final String field, final String value) throws IOException { if (null != value) { write(outputStream, field); write(outputStream, value); writeSeparator(outputStream); } } /** * @param outputStream * @param string */ static final void write(final OutputStream outputStream, final String string) throws IOException { write(outputStream, string.getBytes(DEFAULT_CHARSET)); } /** * @param outputStream * @param data */ static final void write(final OutputStream outputStream, final byte[] data) throws IOException { outputStream.write(data); } /** * @param outputStream */ static final void writeSeparator(final OutputStream outputStream) throws IOException { write(outputStream, "\r\n"); } }