mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-01 22:49:39 +08:00
refactor: use StandardCharsets and remove redundant try-catch
This commit is contained in:
parent
9afd540ca8
commit
02ddf2ef62
@ -40,6 +40,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@ -447,11 +448,7 @@ public class CordovaResourceApi {
|
|||||||
if (base64) {
|
if (base64) {
|
||||||
data = Base64.decode(dataPartAsString, Base64.DEFAULT);
|
data = Base64.decode(dataPartAsString, Base64.DEFAULT);
|
||||||
} else {
|
} else {
|
||||||
try {
|
data = dataPartAsString.getBytes(StandardCharsets.UTF_8);
|
||||||
data = dataPartAsString.getBytes("UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
data = dataPartAsString.getBytes();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
InputStream inputStream = new ByteArrayInputStream(data);
|
InputStream inputStream = new ByteArrayInputStream(data);
|
||||||
return new OpenForReadResult(uri, inputStream, contentType, data.length, null);
|
return new OpenForReadResult(uri, inputStream, contentType, data.length, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user