mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 04:27:38 +02:00
Track and seek to the current position in RandomAccessFileOutputStream
This commit is contained in:
@ -37,21 +37,29 @@ import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
public class RandomAccessFileOutputStream extends OutputStream {
|
||||
private int filePosition;
|
||||
@Nonnull private final RandomAccessFile raf;
|
||||
|
||||
public RandomAccessFileOutputStream(@Nonnull RandomAccessFile raf) {
|
||||
public RandomAccessFileOutputStream(@Nonnull RandomAccessFile raf, int startFilePosition) {
|
||||
this.filePosition = startFilePosition;
|
||||
this.raf = raf;
|
||||
}
|
||||
|
||||
@Override public void write(int b) throws IOException {
|
||||
raf.seek(filePosition);
|
||||
filePosition++;
|
||||
raf.write(b);
|
||||
}
|
||||
|
||||
@Override public void write(byte[] b) throws IOException {
|
||||
raf.seek(filePosition);
|
||||
filePosition += b.length;
|
||||
raf.write(b);
|
||||
}
|
||||
|
||||
@Override public void write(byte[] b, int off, int len) throws IOException {
|
||||
raf.seek(filePosition);
|
||||
filePosition += len;
|
||||
raf.write(b, off, len);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user