Java ByteBuffer Write writeNullTerminatedString(ByteBuffer buf, String s, String encoding)

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

Description

write Null Terminated String

License

Open Source License

Declaration

public static void writeNullTerminatedString(ByteBuffer buf, String s, String encoding) throws IOException 

Method Source Code

//package com.java2s;
/**/*  w w  w . j a  v a2 s.co  m*/
 * Project: ${puma-common.aid}
 * <p/>
 * File Created at 2012-6-6 $Id$
 * <p/>
 * Copyright 2010 dianping.com. All rights reserved.
 * <p/>
 * This software is the confidential and proprietary information of Dianping
 * Company. ("Confidential Information"). You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with dianping.com.
 */

import java.io.IOException;

import java.nio.ByteBuffer;

public class Main {
    public static void writeNullTerminatedString(ByteBuffer buf, String s, String encoding) throws IOException {
        buf.put(s.getBytes(encoding));
        buf.put((byte) 0);
    }
}

Related

  1. writeLong(ByteBuffer buf, long value, int len)
  2. writeLong(ByteBuffer logBuf, long l)
  3. writeLong(long num, ByteBuffer out)
  4. writeLong(long v, ByteBuffer buffer)
  5. writeLTriad(int triad, ByteBuffer bb)
  6. writePackageName(ByteBuffer buffer, String packageName)
  7. writeRemaining(WritableByteChannel channel, ByteBuffer buffer)
  8. writeResBit15(int value, ByteBuffer toBuffer)
  9. writeShortString(ByteBuffer buffer, String s)