|
28 | 28 |
|
29 | 29 | import javax.swing.*; |
30 | 30 | import java.io.IOException; |
31 | | -import java.io.UnsupportedEncodingException; |
32 | 31 | import java.net.URLEncoder; |
33 | 32 | import java.nio.charset.StandardCharsets; |
34 | 33 | import java.util.List; |
@@ -56,19 +55,15 @@ public String doTranslate(@NotNull Lang fromLang, @NotNull Lang toLang, @NotNull |
56 | 55 | String requestParams = getRequestParams(fromLang, toLang, text) |
57 | 56 | .stream() |
58 | 57 | .map(pair -> { |
59 | | - try { |
60 | | - return pair.first.concat("=").concat(URLEncoder.encode(pair.second, StandardCharsets.UTF_8.name())); |
61 | | - } catch (UnsupportedEncodingException e) { |
62 | | - throw new TranslationException(fromLang, toLang, text, e); |
63 | | - } |
| 58 | + return pair.first.concat("=").concat(URLEncoder.encode(pair.second, StandardCharsets.UTF_8)); |
64 | 59 | }) |
65 | 60 | .collect(Collectors.joining("&")); |
66 | 61 | if (!requestParams.isEmpty()) { |
67 | 62 | request.write(requestParams); |
68 | 63 | } |
69 | 64 | String requestBody = getRequestBody(fromLang, toLang, text); |
70 | 65 | if (!requestBody.isEmpty()) { |
71 | | - request.write(URLEncoder.encode(requestBody, StandardCharsets.UTF_8.name())); |
| 66 | + request.write(URLEncoder.encode(requestBody, StandardCharsets.UTF_8)); |
72 | 67 | } |
73 | 68 | String resultText = request.readString(); |
74 | 69 | return parsingResult(fromLang, toLang, text, resultText); |
|
0 commit comments