I am reading a file by using:
int len = (int)(new File(args[0]).length());
FileInputStream fis =
new FileInputStream(args[0]);
byte buf[] = new byte[len];
fis.read(buf);
As I found here. Is it possible to convert byte array buf
to an Int Array
? Is converting the Byte Array
to Int Array
will take significantly more space ?
Edit: my file contains millions of ints like,
100000000 200000000 ..... (written using normal int file wirte). I read it to byte buffer. Now I want to wrap it into IntBuffer array. How to do that ? I dont want to convert each byte to int.
int
is stored on 32 bits,byte
is stored on 8 bits so it will take around 4x more space – Earthstar4 byte
s in oneint
element? In that case this may interest you. – Earthstar