Initial commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.liulishuo.filedownloader.stream;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface FileDownloadOutputStream {
|
||||
void a() throws IOException;
|
||||
|
||||
void a(long j) throws IOException, IllegalAccessException;
|
||||
|
||||
void b(long j) throws IOException, IllegalAccessException;
|
||||
|
||||
void close() throws IOException;
|
||||
|
||||
void write(byte[] bArr, int i, int i2) throws IOException;
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package com.liulishuo.filedownloader.stream;
|
||||
|
||||
import com.liulishuo.filedownloader.util.FileDownloadHelper;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FileDownloadRandomAccessFile implements FileDownloadOutputStream {
|
||||
private final BufferedOutputStream a;
|
||||
private final FileDescriptor b;
|
||||
private final RandomAccessFile c;
|
||||
|
||||
public static class Creator implements FileDownloadHelper.OutputStreamCreator {
|
||||
@Override // com.liulishuo.filedownloader.util.FileDownloadHelper.OutputStreamCreator
|
||||
public FileDownloadOutputStream a(File file) throws IOException {
|
||||
return new FileDownloadRandomAccessFile(file);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.util.FileDownloadHelper.OutputStreamCreator
|
||||
public boolean a() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FileDownloadRandomAccessFile(File file) throws IOException {
|
||||
this.c = new RandomAccessFile(file, "rw");
|
||||
this.b = this.c.getFD();
|
||||
this.a = new BufferedOutputStream(new FileOutputStream(this.c.getFD()));
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.stream.FileDownloadOutputStream
|
||||
public void a() throws IOException {
|
||||
this.a.flush();
|
||||
this.b.sync();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.stream.FileDownloadOutputStream
|
||||
public void b(long j) throws IOException {
|
||||
this.c.seek(j);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.stream.FileDownloadOutputStream
|
||||
public void close() throws IOException {
|
||||
this.a.close();
|
||||
this.c.close();
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.stream.FileDownloadOutputStream
|
||||
public void write(byte[] bArr, int i, int i2) throws IOException {
|
||||
this.a.write(bArr, i, i2);
|
||||
}
|
||||
|
||||
@Override // com.liulishuo.filedownloader.stream.FileDownloadOutputStream
|
||||
public void a(long j) throws IOException {
|
||||
this.c.setLength(j);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user