How to convert a Byte Array to an Int Array

后端 未结 7 1073
生来不讨喜
生来不讨喜 2020-11-28 12:44

I am reading a file by using:

int len = (int)(new File(args[0]).length());
    FileInputStream fis =
        new FileInputStream(args[0]);
    byte buf[] = n         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 13:11

    define "significantly". in java, an int is 4 bytes, so by definition the array would be 4x the space. See: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

    And during the conversion, you have to have both, so during the copy portion, you'd be using even more, if you were copying the whole array at once.

    as for the conversion, there are many related questions:

    Java - converting byte array of audio into integer array

提交回复
热议问题