alexandroid/decompiled/jadx/sources/org/apache/http/entity/FileEntity.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

76 lines
2.2 KiB
Java

package org.apache.http.entity;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.util.Args;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes11.dex */
public class FileEntity extends AbstractHttpEntity implements Cloneable {
protected final File file;
public FileEntity(File file, ContentType contentType) {
this.file = (File) Args.notNull(file, "File");
if (contentType != null) {
setContentType(contentType.toString());
}
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override // org.apache.http.HttpEntity
public InputStream getContent() throws IOException {
return new FileInputStream(this.file);
}
@Override // org.apache.http.HttpEntity
public long getContentLength() {
return this.file.length();
}
@Override // org.apache.http.HttpEntity
public boolean isRepeatable() {
return true;
}
@Override // org.apache.http.HttpEntity
public boolean isStreaming() {
return false;
}
@Override // org.apache.http.HttpEntity
public void writeTo(OutputStream outputStream) throws IOException {
Args.notNull(outputStream, "Output stream");
FileInputStream fileInputStream = new FileInputStream(this.file);
try {
byte[] bArr = new byte[4096];
while (true) {
int read = fileInputStream.read(bArr);
if (read == -1) {
outputStream.flush();
fileInputStream.close();
return;
}
outputStream.write(bArr, 0, read);
}
} catch (Throwable th) {
fileInputStream.close();
throw th;
}
}
@Deprecated
public FileEntity(File file, String str) {
this.file = (File) Args.notNull(file, "File");
setContentType(str);
}
public FileEntity(File file) {
this.file = (File) Args.notNull(file, "File");
}
}