Java File Write via ByteBuffer writeStringData(DataOutputStream mDataOutputStream, String token)

Here you can find the source of writeStringData(DataOutputStream mDataOutputStream, String token)

Description

write String Data

License

Apache License

Declaration

public static void writeStringData(DataOutputStream mDataOutputStream, String token) throws IOException 

Method Source Code

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

import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;

public class Main {
    public static void writeStringData(DataOutputStream mDataOutputStream, String token) throws IOException {
        byte[] name = token.getBytes();
        mDataOutputStream.write(ByteBuffer.allocate(4).putInt(name.length).array());
        mDataOutputStream.flush();//from w w w. j  a va  2s. com
        mDataOutputStream.write(name);
        mDataOutputStream.flush();
    }
}

Related

  1. writeLong(RandomAccessFile raFile, long num)
  2. writeObject(Serializable serializable)
  3. writeShort(int i, DataOutput out)
  4. writeString(ByteArrayOutputStream bout, String val)
  5. writeStringContents(String contents, WritableByteChannel channel)
  6. writeStringToSocketChannel(String text, SocketChannel sc)
  7. writeToFile(String path, ByteOrder byteOrder)
  8. writeUtf8(DataOutput out, String string)
  9. writeVector(DataOutputStream output, float[] vector)