集册 Java实例教程 此函数转换一个

此函数转换一个

欢马劈雪     最近更新时间:2020-01-02 10:19:05

369
此函数将一维字节数组转换为一维int数组
/* 
*来 自
 时 代 J a v a - N o w J a v a . c o m
*/



public class Main{

    public static void main(String[] argv) throws Exception{

        byte[] in = new byte[]{34,35,36,37,37,37,67,68,69};

        System.out.println(java.util.Arrays.toString(convertArraytoInt(in)));

    }

    /**

     * This function converts an one-dimensional array of bytes into a

     * one-dimensional array of int

     * 

     * @param in

     *            the array to be converted

     * @return out the one-dimensional int-array that corresponds the input

     */

    public static int[] convertArraytoInt(byte[] in) {

        int[] out = new int[in.length];

        
展开阅读全文