Clean code

This commit is contained in:
FongMi 2023-06-01 14:00:22 +08:00
parent 7c9a63c4dc
commit 90ff5c9376
2 changed files with 3 additions and 7 deletions

View File

@ -460,7 +460,7 @@ public class API {
public Object[] proxySub(Map<String, String> params) throws Exception { public Object[] proxySub(Map<String, String> params) throws Exception {
String fileId = params.get("file_id"); String fileId = params.get("file_id");
Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth()); Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth());
byte[] body = Utils.getUTF8(res.body().bytes()); byte[] body = Utils.toUtf8(res.body().bytes());
Object[] result = new Object[3]; Object[] result = new Object[3];
result[0] = 200; result[0] = 200;
result[1] = "application/octet-stream"; result[1] = "application/octet-stream";

View File

@ -56,12 +56,8 @@ public class Utils {
return Arrays.equals(bytes, newBytes); return Arrays.equals(bytes, newBytes);
} }
public static byte[] getUTF8(byte[] bytes) throws Exception { public static byte[] toUtf8(byte[] bytes) throws Exception {
if (isGBK(bytes)) { return isGBK(bytes) ? new String(bytes, Charset.forName("GBK")).getBytes("UTF-8") : bytes;
return new String(bytes, Charset.forName("GBK")).getBytes("UTF-8");
} else {
return bytes;
}
} }
public static boolean isSub(String ext) { public static boolean isSub(String ext) {