I need to read a file around 2 MB into a byte array.
var fis = Java.use("java.io.FileInputStream");
var file = fis.$new("/data/local/file.txt");
var fileBytes = new Uint8Array(file.available());
var x;
while ((x = file.read()) != -1)
fileBytes.push(x);
I'm using the code above but it's reading ~100 kb/s which takes ~20 seconds in my case.
I also tried with ByteArrayOutputStream with 1, 4, 16kb buffers but result isn't any different.
I believe a native Java function which takes Inputfilestream and returns a bytearray will fix my issue, but I couldn't find any.
How can I make this process faster?
I'm actually trying to use it with okio.ByteString
which has a .read()
method, but I can't access it from Frida. It's undefined.