Java File Write via ByteBuffer writeInt(OutputStream out, int i)

Here you can find the source of writeInt(OutputStream out, int i)

Description

write Int

License

Open Source License

Declaration

public static void writeInt(OutputStream out, int i) throws IOException 

Method Source Code

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

import java.io.IOException;

import java.io.OutputStream;
import java.nio.ByteBuffer;

public class Main {
    public static void writeInt(OutputStream out, int i) throws IOException {
        byte[] bytes = new byte[Integer.BYTES];
        ByteBuffer.wrap(bytes).putInt(i);
        out.write(bytes);/*from  w w w.j  av a 2  s .c  om*/
    }

    public static byte[] writeInt(int i) {
        byte[] bytes = new byte[Integer.BYTES];
        ByteBuffer.wrap(bytes).putInt(i);
        return bytes;
    }
}

Related

  1. writeFileAsStringArray(File file, String[] par2DataArray)
  2. writeFileNIO(String txt, File fyl)
  3. writeFloat(OutputStream os, float val, ByteOrder bo)
  4. writeInt(OutputStream os, int val, ByteOrder bo)
  5. writeInt(OutputStream out, ByteOrder order, int i)
  6. writeInt(WritableByteChannel channel, int val)
  7. writeInt(WritableByteChannel channel, int value)
  8. writeInt(WritableByteChannel channel, int value)
  9. writeLong(OutputStream in, long i)