|
27 | 27 | import java.io.OutputStream; |
28 | 28 | import java.io.OutputStreamWriter; |
29 | 29 | import java.io.Writer; |
| 30 | +import java.net.URI; |
30 | 31 | import java.net.URL; |
31 | 32 | import java.net.URLConnection; |
32 | 33 | import java.nio.charset.StandardCharsets; |
@@ -155,19 +156,19 @@ private static void expandDataFileRules(Path file) throws IOException { |
155 | 156 | } |
156 | 157 |
|
157 | 158 | private static void getNFKCDataFilesFromIcuProject(String releaseTag) throws IOException { |
158 | | - URL icuTagsURL = new URL(ICU_GIT_TAG_URL + "/"); |
159 | | - URL icuReleaseTagURL = new URL(icuTagsURL, releaseTag + "/"); |
160 | | - URL norm2url = new URL(icuReleaseTagURL, ICU_DATA_NORM2_PATH + "/"); |
| 159 | + URI icuTagsURI = URI.create(ICU_GIT_TAG_URL + "/"); |
| 160 | + URI icuReleaseTagURI = icuTagsURI.resolve(releaseTag + "/"); |
| 161 | + URI norm2uri = icuReleaseTagURI.resolve(ICU_DATA_NORM2_PATH + "/"); |
161 | 162 |
|
162 | 163 | System.err.print("Downloading " + NFKC_TXT + " ... "); |
163 | | - download(new URL(norm2url, NFKC_TXT), NFKC_TXT); |
| 164 | + download(norm2uri.resolve(NFKC_TXT), NFKC_TXT); |
164 | 165 | System.err.println("done."); |
165 | 166 | System.err.print("Downloading " + NFKC_CF_TXT + " ... "); |
166 | | - download(new URL(norm2url, NFKC_CF_TXT), NFKC_CF_TXT); |
| 167 | + download(norm2uri.resolve(NFKC_CF_TXT), NFKC_CF_TXT); |
167 | 168 | System.err.println("done."); |
168 | 169 |
|
169 | 170 | System.err.print("Downloading " + NFKC_CF_TXT + " and making diacritic rules one-way ... "); |
170 | | - URLConnection connection = openConnection(new URL(norm2url, NFC_TXT)); |
| 171 | + URLConnection connection = openConnection(norm2uri.resolve(NFC_TXT).toURL()); |
171 | 172 | try (BufferedReader reader = |
172 | 173 | new BufferedReader( |
173 | 174 | new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); |
@@ -210,8 +211,8 @@ private static void getNFKCDataFilesFromIcuProject(String releaseTag) throws IOE |
210 | 211 | System.err.println("done."); |
211 | 212 | } |
212 | 213 |
|
213 | | - private static void download(URL url, String outputFile) throws IOException { |
214 | | - final URLConnection connection = openConnection(url); |
| 214 | + private static void download(URI uri, String outputFile) throws IOException { |
| 215 | + final URLConnection connection = openConnection(uri.toURL()); |
215 | 216 | try (InputStream inputStream = connection.getInputStream(); |
216 | 217 | OutputStream outputStream = Files.newOutputStream(Path.of(outputFile))) { |
217 | 218 | inputStream.transferTo(outputStream); |
|
0 commit comments