Here you can find the source of writeStreamText(OutputStream out, String text)
Parameter | Description |
---|---|
out | output stream |
text | text data |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeStreamText(OutputStream out, String text) throws IOException
//package com.java2s; // New BSD License import java.io.BufferedWriter; import java.io.Closeable; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; public class Main { private static final String DEFAULT_ENCODING = "UTF8"; /**/*from w w w . j ava2s . c o m*/ * Writes the text data to the specified output stream. * * @param out output stream * @param text text data * @throws IOException */ public static void writeStreamText(OutputStream out, String text) throws IOException { writeLinesCommon(out, text); } private static void writeLinesCommon(OutputStream out, String text) throws IOException { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(out, DEFAULT_ENCODING)); writer.write(text); } finally { close(writer); } } private static void close(Closeable c) { if (c != null) { try { c.close(); } catch (IOException ex) { } } } }