Here you can find the source of writeAll(String data, OutputStream outputStream, Charset charset)
Parameter | Description |
---|---|
data | Source string |
outputStream | Output stream |
charset | Convert string to bytes according to given Charset |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeAll(String data, OutputStream outputStream, Charset charset) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.OutputStream; import java.nio.charset.Charset; public class Main { private static final String DEFAULT_CHARSET = "UTF-8"; /**/*from w ww . j av a2 s . c o m*/ * Write string to byte stream * @param data Source string * @param outputStream Output stream * @param charset Convert string to bytes according to given {@link Charset} * @throws IOException */ public static void writeAll(String data, OutputStream outputStream, Charset charset) throws IOException { writeAll(data, outputStream, charset.name()); } /** * Write string to byte stream * @param data Source string * @param outputStream Output stream * @param charset Convert string to bytes according to given * @throws IOException */ public static void writeAll(String data, OutputStream outputStream, String charset) throws IOException { if ((data != null) && (data.length() > 0)) { outputStream.write(data.getBytes(charset)); } } /** * Write string to byte stream * @param data Source string * @param outputStream Output stream * @throws IOException */ public static void writeAll(String data, OutputStream outputStream) throws IOException { writeAll(data, outputStream, DEFAULT_CHARSET); } }