package okhttp3.internal.cache2; import java.io.IOException; import java.nio.channels.FileChannel; import o.C14957gcv; import o.C15111ghZ; /* loaded from: classes6.dex */ public final class FileOperator { private final FileChannel fileChannel; public FileOperator(FileChannel fileChannel) { C14957gcv.e(fileChannel, ""); this.fileChannel = fileChannel; } public final void read(long j, C15111ghZ c15111ghZ, long j2) { C14957gcv.e(c15111ghZ, ""); if (j2 < 0) { throw new IndexOutOfBoundsException(); } while (j2 > 0) { long transferTo = this.fileChannel.transferTo(j, j2, c15111ghZ); j += transferTo; j2 -= transferTo; } } public final void write(long j, C15111ghZ c15111ghZ, long j2) throws IOException { C14957gcv.e(c15111ghZ, ""); if (j2 < 0 || j2 > c15111ghZ.c) { throw new IndexOutOfBoundsException(); } while (j2 > 0) { long transferFrom = this.fileChannel.transferFrom(c15111ghZ, j, j2); j += transferFrom; j2 -= transferFrom; } } }