Java OutputStream Write String writeString(OutputStream out, String s)

Here you can find the source of writeString(OutputStream out, String s)

Description

write String

License

LGPL

Declaration

public static void writeString(OutputStream out, String s) throws IOException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.IOException;

import java.io.OutputStream;

public class Main {
    public static void writeString(OutputStream out, String s) throws IOException {
        byte[] buf = s.getBytes("UTF8");

        short len = (short) buf.length;

        out.write((len >> 8) & 0xFF);
        out.write(len & 0xFF);//from  ww  w.j  av a 2 s  .c om

        out.write(buf);
    }
}

Related

  1. writeString(OutputStream os, String s)
  2. writeString(OutputStream os, String s)
  3. writeString(OutputStream os, String s)
  4. writeString(OutputStream os, String str)
  5. writeString(OutputStream os, String text)
  6. writeString(OutputStream out, String s)
  7. writeString(OutputStream out, String s)
  8. writeString(OutputStream out, String s)
  9. writeString(OutputStream out, String s)