Here you can find the source of writeString(ObjectOutputStream stream, String string)
Parameter | Description |
---|---|
stream | Stream to write to |
string | String to write |
Parameter | Description |
---|---|
IOException | If there was an error writing the String |
public static void writeString(ObjectOutputStream stream, String string) throws IOException
//package com.java2s; /*/*from w ww.ja va 2 s . co m*/ * This file is part of SpaceModule (http://spacebukkit.xereo.net/). * * SpaceModule is free software: you can redistribute it and/or modify it under the terms of the * Attribution-NonCommercial-ShareAlike Unported (CC BY-NC-SA) license as published by the Creative * Common organization, either version 3.0 of the license, or (at your option) any later version. * * SpaceBukkit 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 * Attribution-NonCommercial-ShareAlike Unported (CC BY-NC-SA) license for more details. * * You should have received a copy of the Attribution-NonCommercial-ShareAlike Unported (CC BY-NC-SA) * license along with this program. If not, see <http://creativecommons.org/licenses/by-nc-sa/3.0/>. */ import java.io.IOException; import java.io.ObjectOutputStream; public class Main { /** * Writes a String to an ObjectOutputStream * @param stream Stream to write to * @param string String to write * @throws IOException If there was an error writing the String */ public static void writeString(ObjectOutputStream stream, String string) throws IOException { stream.writeShort((short) string.length()); for (int i = 0; i < string.length(); i++) { stream.writeChar(string.charAt(i)); } } }