]> git.ktnx.net Git - mobile-ledger.git/commitdiff
replace two literal charset names with pre-defined constants
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 28 Jan 2019 20:01:35 +0000 (22:01 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 29 Jan 2019 02:49:54 +0000 (02:49 +0000)
app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java
app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java

index 56a26621e24b120e2e3b86789ae5c1eb03b95f06..f66da7a8e6497f708499f675ddf16157bbd76238 100644 (file)
@@ -42,6 +42,7 @@ import java.lang.ref.WeakReference;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
@@ -131,8 +132,8 @@ public class RetrieveTransactionsTask
 
                         ParserState state = ParserState.EXPECTING_ACCOUNT;
                         String line;
-                        BufferedReader buf =
-                                new BufferedReader(new InputStreamReader(resp, "UTF-8"));
+                        BufferedReader buf = new BufferedReader(
+                                new InputStreamReader(resp, StandardCharsets.UTF_8));
 
                         int processedTransactionCount = 0;
                         int transactionId = 0;
index fae87bc37ae8bec621f5917650634d7508d2c1ca..f23cba323f5e9d0bc5a32c8ebd2bf9e56dc455d9 100644 (file)
@@ -33,6 +33,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -82,7 +83,7 @@ public class SaveTransactionTask extends AsyncTask<LedgerTransaction, Void, Void
 
         try (OutputStream req = http.getOutputStream()) {
             Log.d("network", "Request body: " + body);
-            req.write(body.getBytes("ASCII"));
+            req.write(body.getBytes(StandardCharsets.US_ASCII));
 
             try (InputStream resp = http.getInputStream()) {
                 Log.d("update_accounts", String.valueOf(http.getResponseCode()));
index e6cc9acb73c5067bf5dfc5eac260bfcbf4821ef2..67adef060db0c0b77031a66c3cc6a9db491c60ea 100644 (file)
@@ -26,6 +26,7 @@ import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 
 public final class NetworkUtil {
     private static final int thirtySeconds = 30000;
@@ -39,8 +40,8 @@ public final class NetworkUtil {
         if (use_auth) {
             final String auth_user = profile.getAuthUserName();
             final String auth_password = profile.getAuthPassword();
-            final byte[] bytes =
-                    (String.format("%s:%s", auth_user, auth_password)).getBytes("UTF-8");
+            final byte[] bytes = (String.format("%s:%s", auth_user, auth_password))
+                    .getBytes(StandardCharsets.UTF_8);
             final String value = Base64.encodeToString(bytes, Base64.DEFAULT);
             http.setRequestProperty("Authorization", "Basic " + value);
         }