58 lines
1.7 KiB
Java
58 lines
1.7 KiB
Java
package com.baidu.cloud.videocache;
|
|
|
|
import android.text.TextUtils;
|
|
import android.webkit.MimeTypeMap;
|
|
import java.io.Closeable;
|
|
import java.io.IOException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLEncoder;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class z {
|
|
private static final Logger a = LoggerFactory.getLogger("ProxyCacheUtils");
|
|
|
|
static String a(String str) {
|
|
MimeTypeMap singleton = MimeTypeMap.getSingleton();
|
|
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
|
|
if (TextUtils.isEmpty(fileExtensionFromUrl)) {
|
|
return null;
|
|
}
|
|
return singleton.getMimeTypeFromExtension(fileExtensionFromUrl);
|
|
}
|
|
|
|
static void a(Closeable closeable) {
|
|
if (closeable != null) {
|
|
try {
|
|
closeable.close();
|
|
} catch (IOException e) {
|
|
a.error("Error closing resource", e);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void a(byte[] bArr, long j, int i) {
|
|
t.a(bArr, "Buffer must be not null!");
|
|
t.a(j >= 0, "Data offset must be positive!");
|
|
t.a(i >= 0 && i <= bArr.length, "Length must be in range [0..buffer.length]");
|
|
}
|
|
|
|
public static String b(String str) {
|
|
try {
|
|
return URLEncoder.encode(str, "utf-8");
|
|
} catch (UnsupportedEncodingException e) {
|
|
throw new RuntimeException("Error encoding url", e);
|
|
}
|
|
}
|
|
|
|
static String c(String str) {
|
|
try {
|
|
return URLDecoder.decode(str, "utf-8");
|
|
} catch (UnsupportedEncodingException e) {
|
|
throw new RuntimeException("Error decoding url", e);
|
|
}
|
|
}
|
|
}
|