I am trying to write a java function that will change 1 byte in a large file. How can I read in and write to a specific address in a file with java on android? I have tried fis.read(byte b[], int off, int len) and I get a force close every time.
Each Byte File System is a mountable file system. The root file system is the first file system mounted. Subsequent file systems can be mounted on any directory within the root file system or on a directory within any mounted file system.
Use RandomAccessFile
.
Kickoff example:
RandomAccessFile raf = new RandomAccessFile(file, "rw");
try {
raf.seek(5); // Go to byte at offset position 5.
raf.write(70); // Write byte 70 (overwrites original byte at this offset).
} finally {
raf.close(); // Flush/save changes and close resource.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With