Here you can find the source of writeStringToStream(final String s, final OutputStream outputStream)
Parameter | Description |
---|---|
s | a parameter |
outputStream | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
private static void writeStringToStream(final String s, final OutputStream outputStream) throws IOException
//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(); } }