Here you can find the source of writeInt(OutputStream os, int val, ByteOrder bo)
Parameter | Description |
---|---|
os | a parameter |
val | a parameter |
bo | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeInt(OutputStream os, int val, ByteOrder bo) throws IOException
//package com.java2s; /*//from w w w .j a v a2 s .c o m Copyright (c) 2009-2011 Speech Group at Informatik 5, Univ. Erlangen-Nuremberg, GERMANY Korbinian Riedhammer Tobias Bocklet This file is part of the Java Speech Toolkit (JSTK). The JSTK is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The JSTK is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the JSTK. If not, see <http://www.gnu.org/licenses/>. */ import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { /** * Write an int to the OutputStream and advance the stream * pointer respectively. * @param os * @param val * @param bo * @return * @throws IOException */ public static void writeInt(OutputStream os, int val, ByteOrder bo) throws IOException { ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE / 8); bb.order(bo); bb.putInt(val); os.write(bb.array()); } /** * Write the given int array to the OutputStream using given ByteOrder * @param os * @param buf * @param bo * @throws IOException */ public static void writeInt(OutputStream os, int[] buf, ByteOrder bo) throws IOException { ByteBuffer bb = ByteBuffer.allocate(buf.length * Integer.SIZE / 8); bb.order(bo); for (int d : buf) bb.putInt(d); os.write(bb.array()); } }