Java OutputStream Write String writeString(OutputStream os, String str)

Here you can find the source of writeString(OutputStream os, String str)

Description

Writes a string to the specified output stream.

License

Open Source License

Parameter

Parameter Description
os The output stream.
str The string.

Exception

Parameter Description
IOException If an I/O error occurs.

Declaration

public static void writeString(OutputStream os, String str) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    /**//from   w  w w. j  av a  2 s  .  c  o m
     * Writes a string to the specified output stream.
     * @param os The output stream.
     * @param str The string.
     * @throws IOException If an I/O error occurs.
     */
    public static void writeString(OutputStream os, String str) throws IOException {
        for (char c : str.toCharArray()) {
            os.write(c);
        }
        os.write('\0');
    }
}

Related

  1. writeString(ObjectOutputStream stream, String string)
  2. writeString(OutputStream os, String request, String charsetName)
  3. writeString(OutputStream os, String s)
  4. writeString(OutputStream os, String s)
  5. writeString(OutputStream os, String s)
  6. writeString(OutputStream os, String text)
  7. writeString(OutputStream out, String s)
  8. writeString(OutputStream out, String s)
  9. writeString(OutputStream out, String s)