Java ByteBuffer Write writeString(ByteBuffer buf, String s)

Here you can find the source of writeString(ByteBuffer buf, String s)

Description

write String

License

LGPL

Declaration

public static void writeString(ByteBuffer buf, String s) 

Method Source Code

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

import java.io.*;

import java.nio.ByteBuffer;

public class Main {
    public static void writeString(String s, DataOutput out) throws Exception {
        if (s != null) {
            out.write(1);//from   w ww .  j a  va  2s  . c om
            out.writeUTF(s);
        } else {
            out.write(0);
        }
    }

    public static void writeString(ByteBuffer buf, String s) {
        for (int i = 0; i < s.length(); i++)
            buf.put((byte) s.charAt(i));
    }
}

Related

  1. writeShortString(ByteBuffer buffer, String s)
  2. writeSign(ByteBuffer bb)
  3. writeSignedVarint(ByteBuffer buffer, int val)
  4. writeSize(final int s, ByteBuffer buffer)
  5. writeSlice(ByteBuffer src, int number, ByteBuffer dst)
  6. writeString(ByteBuffer buf, String str)
  7. writeString(ByteBuffer buf, String value)
  8. writeString(ByteBuffer buffer, String string)
  9. writeString(ByteBuffer byteBuffer, String str)