Java OutputStream Write String writeStringToStream(final String s, final OutputStream outputStream)

Here you can find the source of writeStringToStream(final String s, final OutputStream outputStream)

Description

Writes the given string to the stream.

License

Open Source License

Parameter

Parameter Description
s a parameter
outputStream a parameter

Exception

Parameter Description
IOException an exception

Declaration

private static void writeStringToStream(final String s, final OutputStream outputStream) throws IOException 

Method Source Code

//package com.java2s;
/**//from  ww w.jav  a  2 s. c o  m
 *
 *  BibSonomy-Web-Common - A blue social bookmark and publication sharing system.
 *
 *  Copyright (C) 2006 - 2011 Knowledge & Data Engineering Group,
 *                            University of Kassel, Germany
 *                            http://www.kde.cs.uni-kassel.de/
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.io.IOException;

import java.io.OutputStream;
import java.io.StringReader;

public class Main {
    /** Writes the given string to the stream.
     * 
     * @param s
     * @param outputStream
     * @throws IOException
     */
    private static void writeStringToStream(final String s, final OutputStream outputStream) throws IOException {
        final StringReader reader = new StringReader(s);
        int b;
        while ((b = reader.read()) >= 0) {
            outputStream.write(b);
        }
        outputStream.flush();
    }
}

Related

  1. writeStringSmart(ByteArrayOutputStream baos, String s, Map knownStrings)
  2. writeStringStringMap(Map map, OutputStream os)
  3. writeStringStringMap(Map map, OutputStream os)
  4. WriteStringToOutputStream(String data, OutputStream os)
  5. writeStringToStream(final OutputStream stream, final String string)
  6. writeStringToStream(OutputStream out, String contents, String charset)
  7. writeStringToUtf8(final String str, final OutputStream out)