Skip to content

Commit a3c8bd4

Browse files
author
taylor.smock
committed
See #17858: Replace most calls to StandardCharsets.UTF_8.name() with StandardCharsets.UTF_8
This (in many cases) also removes catches for `UnsupportedEncodingException`. git-svn-id: https://josm.openstreetmap.de/svn/trunk@19121 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent 0d2e9e9 commit a3c8bd4

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed

src/org/openstreetmap/josm/data/Preferences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ protected void save(File prefFile, Stream<Entry<String, Setting<?>>> settings, b
443443
}
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) {
449449
throw new IOException(e);

src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected void cachePluginList(String site, String list) {
252252
}
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();
258258
} catch (IOException e) {

src/org/openstreetmap/josm/tools/Utils.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.io.FileNotFoundException;
1515
import java.io.IOException;
1616
import java.io.InputStream;
17-
import java.io.UnsupportedEncodingException;
1817
import java.net.MalformedURLException;
1918
import java.net.URI;
2019
import java.net.URISyntaxException;
@@ -1138,12 +1137,7 @@ public static String fixURLQuery(String url) {
11381137
* @since 8304
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

11491143
/**
@@ -1158,12 +1152,7 @@ public static String encodeUrl(String s) {
11581152
* @since 8304
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

11691158
/**

test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private void testShow(final String arg, String expected) throws InterruptedExcep
129129
t.start();
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);
135135
}

0 commit comments

Comments
 (0)