Changeset 19121 in josm


Ignore:
Timestamp:
2024-06-20T16:40:27+02:00 (4 months ago)
Author:
taylor.smock
Message:

See #17858: Replace most calls to StandardCharsets.UTF_8.name() with StandardCharsets.UTF_8

This (in many cases) also removes catches for UnsupportedEncodingException.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r19095 r19121  
    444444
    445445        try (PreferencesWriter writer = new PreferencesWriter(
    446                 new PrintWriter(prefFile + "_tmp", StandardCharsets.UTF_8.name()), false, defaults)) {
     446                new PrintWriter(prefFile + "_tmp", StandardCharsets.UTF_8), false, defaults)) {
    447447            writer.write(settings);
    448448        } catch (SecurityException e) {
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r18211 r19121  
    253253        File cacheFile = createSiteCacheFile(pluginDir, site);
    254254        getProgressMonitor().subTask(tr("Writing plugin list to local cache ''{0}''", cacheFile.toString()));
    255         try (PrintWriter writer = new PrintWriter(cacheFile, StandardCharsets.UTF_8.name())) {
     255        try (PrintWriter writer = new PrintWriter(cacheFile, StandardCharsets.UTF_8)) {
    256256            writer.write(list);
    257257            writer.flush();
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r19112 r19121  
    1515import java.io.IOException;
    1616import java.io.InputStream;
    17 import java.io.UnsupportedEncodingException;
    1817import java.net.MalformedURLException;
    1918import java.net.URI;
     
    11391138     */
    11401139    public static String encodeUrl(String s) {
    1141         final String enc = StandardCharsets.UTF_8.name();
    1142         try {
    1143             return URLEncoder.encode(s, enc);
    1144         } catch (UnsupportedEncodingException e) {
    1145             throw new IllegalStateException(e);
    1146         }
     1140        return URLEncoder.encode(s, StandardCharsets.UTF_8);
    11471141    }
    11481142
     
    11591153     */
    11601154    public static String decodeUrl(String s) {
    1161         final String enc = StandardCharsets.UTF_8.name();
    1162         try {
    1163             return URLDecoder.decode(s, enc);
    1164         } catch (UnsupportedEncodingException e) {
    1165             throw new IllegalStateException(e);
    1166         }
     1155        return URLDecoder.decode(s, StandardCharsets.UTF_8);
    11671156    }
    11681157
  • trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    r18893 r19121  
    130130            t.join();
    131131            System.out.flush();
    132             assertEquals(expected, baos.toString(StandardCharsets.UTF_8.name()).trim());
     132            assertEquals(expected, baos.toString(StandardCharsets.UTF_8).trim());
    133133        } finally {
    134134            System.setOut(old);
Note: See TracChangeset for help on using the changeset viewer.