List of usage examples for java.nio IntBuffer put
public IntBuffer put(int[] src, int off, int len)
From source file:Main.java
public static void main(String[] args) { IntBuffer bb = IntBuffer.allocate(10); bb.put(new int[] { 100, 123, 123, 123, 1 }, 0, 1); System.out.println(bb.toString()); }
From source file:com.atilika.kuromoji.trie.DoubleArrayTrie.java
public void write(OutputStream output) throws IOException { baseBuffer.rewind();/*w w w . j a v a 2s. com*/ checkBuffer.rewind(); tailBuffer.rewind(); int baseCheckSize = Math.min(maxBaseCheckIndex + 64, baseBuffer.capacity()); int tailSize = Math.min(tailIndex - TAIL_OFFSET + 64, tailBuffer.capacity()); DataOutputStream dataOutput = new DataOutputStream(new BufferedOutputStream(output)); dataOutput.writeBoolean(compact); dataOutput.writeInt(baseCheckSize); dataOutput.writeInt(tailSize); WritableByteChannel channel = Channels.newChannel(dataOutput); ByteBuffer tmpBuffer = ByteBuffer.allocate(baseCheckSize * 4); IntBuffer tmpIntBuffer = tmpBuffer.asIntBuffer(); tmpIntBuffer.put(baseBuffer.array(), 0, baseCheckSize); tmpBuffer.rewind(); channel.write(tmpBuffer); tmpBuffer = ByteBuffer.allocate(baseCheckSize * 4); tmpIntBuffer = tmpBuffer.asIntBuffer(); tmpIntBuffer.put(checkBuffer.array(), 0, baseCheckSize); tmpBuffer.rewind(); channel.write(tmpBuffer); tmpBuffer = ByteBuffer.allocate(tailSize * 2); CharBuffer tmpCharBuffer = tmpBuffer.asCharBuffer(); tmpCharBuffer.put(tailBuffer.array(), 0, tailSize); tmpBuffer.rewind(); channel.write(tmpBuffer); dataOutput.flush(); }