refactor: use StandardCharsets and remove redundant try-catch

This commit is contained in:
エリス 2024-12-29 03:00:06 +09:00
parent 9afd540ca8
commit 02ddf2ef62
No known key found for this signature in database
GPG Key ID: 2E5FF17FB26AF7F2

View File

@ -40,6 +40,7 @@ import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.zip.GZIPInputStream;
@ -447,11 +448,7 @@ public class CordovaResourceApi {
if (base64) {
data = Base64.decode(dataPartAsString, Base64.DEFAULT);
} else {
try {
data = dataPartAsString.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
data = dataPartAsString.getBytes();
}
data = dataPartAsString.getBytes(StandardCharsets.UTF_8);
}
InputStream inputStream = new ByteArrayInputStream(data);
return new OpenForReadResult(uri, inputStream, contentType, data.length, null);