- Timestamp:
- 2013-12-28T00:30:15+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r6362 r6552 232 232 try { 233 233 String toXML = Main.pref.toXML(true); 234 InputStream is = new ByteArrayInputStream(toXML.getBytes( "UTF-8"));234 InputStream is = new ByteArrayInputStream(toXML.getBytes(Utils.UTF_8)); 235 235 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); 236 236 builderFactory.setValidating(false); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r6380 r6552 596 596 597 597 final PrintWriter out = new PrintWriter(new OutputStreamWriter( 598 new FileOutputStream(prefFile + "_tmp"), "utf-8"), false);598 new FileOutputStream(prefFile + "_tmp"), Utils.UTF_8), false); 599 599 out.print(toXML(false)); 600 600 Utils.close(out); … … 621 621 if (!Main.applet) { 622 622 File pref = getPreferenceFile(); 623 BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), "utf-8"));623 BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), Utils.UTF_8)); 624 624 try { 625 625 validateXML(in); 626 626 Utils.close(in); 627 in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), "utf-8"));627 in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), Utils.UTF_8)); 628 628 fromXML(in); 629 629 } finally { -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r6551 r6552 6 6 import java.io.InputStreamReader; 7 7 import java.io.Reader; 8 import java.io.UnsupportedEncodingException;9 8 import java.util.ArrayList; 10 9 import java.util.Collection; … … 368 367 * @param internalConfigFile the filename in data/validator 369 368 * @throws ParseException if the config file does not match MapCSS syntax 370 * @throws UnsupportedEncodingException if UTF-8 charset is not supported on the platform371 369 */ 372 private void addMapCSS(String internalConfigFile) throws ParseException , UnsupportedEncodingException{373 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/" + internalConfigFile + ".mapcss"), "UTF-8"));370 private void addMapCSS(String internalConfigFile) throws ParseException { 371 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/" + internalConfigFile + ".mapcss"), Utils.UTF_8)); 374 372 } 375 373 -
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r6533 r6552 26 26 import org.openstreetmap.josm.data.validation.TestError; 27 27 import org.openstreetmap.josm.io.MirroredInputStream; 28 import org.openstreetmap.josm.tools.Utils; 28 29 29 30 /** … … 53 54 super.initialize(); 54 55 if (ENGINE != null) { 55 ENGINE.eval(new InputStreamReader(new MirroredInputStream("resource://data/validator/opening_hours.js"), "UTF-8"));56 ENGINE.eval(new InputStreamReader(new MirroredInputStream("resource://data/validator/opening_hours.js"), Utils.UTF_8)); 56 57 // fake country/state to not get errors on holidays 57 58 ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};"); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r6529 r6552 14 14 import java.io.IOException; 15 15 import java.io.InputStreamReader; 16 import java.io.UnsupportedEncodingException;17 16 import java.text.MessageFormat; 18 17 import java.util.ArrayList; … … 211 210 try { 212 211 MirroredInputStream s = new MirroredInputStream(source); 213 InputStreamReader r; 214 try { 215 r = new InputStreamReader(s, "UTF-8"); 216 } catch (UnsupportedEncodingException e) { 217 r = new InputStreamReader(s); 218 } 219 reader = new BufferedReader(r); 212 reader = new BufferedReader(new InputStreamReader(s, Utils.UTF_8)); 220 213 221 214 String okValue = null; -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r6529 r6552 128 128 } 129 129 if (en.hasTag("highway", "turning_circle", "bus_stop") 130 || en.hasTag("amenity", "parking_entrance") 130 131 || en.hasTag("railway", "buffer_stop") 131 132 || OsmUtils.isTrue(en.get("noexit")) 133 || en.hasKey("entrance") 132 134 || en.hasKey("barrier")) { 133 135 continue; -
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r6525 r6552 10 10 import java.awt.event.KeyEvent; 11 11 import java.io.IOException; 12 import java.io.UnsupportedEncodingException;13 12 import java.net.URL; 14 13 import java.util.regex.Matcher; … … 31 30 import org.openstreetmap.josm.tools.LanguageInfo; 32 31 import org.openstreetmap.josm.tools.OpenBrowser; 32 import org.openstreetmap.josm.tools.Utils; 33 33 import org.openstreetmap.josm.tools.WikiReader; 34 34 … … 90 90 Main.pref.put("cache.motd.html.java", myJava); 91 91 Main.pref.put("cache.motd.html.lang", myLang); 92 try { 93 return motd.getBytes("utf-8"); 94 } catch(UnsupportedEncodingException e){ 95 e.printStackTrace(); 96 return new byte[0]; 97 } 92 return motd.getBytes(Utils.UTF_8); 98 93 } 99 94 -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
r6380 r6552 188 188 Main.info("Try loading obsolete bookmarks file"); 189 189 BufferedReader in = new BufferedReader(new InputStreamReader( 190 new FileInputStream(bookmarkFile), "utf-8"));190 new FileInputStream(bookmarkFile), Utils.UTF_8)); 191 191 192 192 for (String line = in.readLine(); line != null; line = in.readLine()) { -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r6316 r6552 370 370 connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000); 371 371 InputStream inputStream = connection.getInputStream(); 372 InputSource inputSource = new InputSource(new InputStreamReader(inputStream, "UTF-8"));372 InputSource inputSource = new InputSource(new InputStreamReader(inputStream, Utils.UTF_8)); 373 373 NameFinderResultParser parser = new NameFinderResultParser(); 374 374 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, parser); -
trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
r5939 r6552 50 50 con = Utils.openHttpConnection(u); 51 51 con.connect(); 52 in = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"));52 in = new BufferedReader(new InputStreamReader(con.getInputStream(), Utils.UTF_8)); 53 53 return prepareHelpContent(in, dotest, u); 54 54 } catch(MalformedURLException e) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r6289 r6552 95 95 public InputStream getSourceInputStream() throws IOException { 96 96 if (css != null) { 97 return new ByteArrayInputStream(css.getBytes( "UTF-8"));97 return new ByteArrayInputStream(css.getBytes(Utils.UTF_8)); 98 98 } 99 99 MirroredInputStream in = new MirroredInputStream(url); -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r6380 r6552 24 24 import java.io.IOException; 25 25 import java.io.InputStreamReader; 26 import java.io.UnsupportedEncodingException;27 26 import java.net.MalformedURLException; 28 27 import java.net.URL; … … 1229 1228 1230 1229 MirroredInputStream stream = new MirroredInputStream(url); 1231 InputStreamReader r; 1232 try { 1233 r = new InputStreamReader(stream, "UTF-8"); 1234 } catch (UnsupportedEncodingException e) { 1235 r = new InputStreamReader(stream); 1236 } 1237 reader = new BufferedReader(r); 1230 reader = new BufferedReader(new InputStreamReader(stream, Utils.UTF_8)); 1238 1231 1239 1232 String line; -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java
r6360 r6552 10 10 import java.io.InputStreamReader; 11 11 import java.io.Reader; 12 import java.io.UnsupportedEncodingException;13 12 import java.util.Collection; 14 13 import java.util.LinkedList; … … 162 161 zipIcons = s.getFile(); 163 162 } 164 InputStreamReader r; 165 try { 166 r = new InputStreamReader(zip == null ? s : zip, "UTF-8"); 167 } catch (UnsupportedEncodingException e) { 168 r = new InputStreamReader(zip == null ? s: zip); 169 } 163 InputStreamReader r = new InputStreamReader(zip == null ? s : zip, Utils.UTF_8); 170 164 try { 171 165 tp = readAll(new BufferedReader(r), validate); -
trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
r6102 r6552 8 8 import java.io.FileOutputStream; 9 9 import java.io.IOException; 10 import java.io.UnsupportedEncodingException;11 10 12 11 import org.openstreetmap.josm.Main; … … 120 119 public String updateForceString() throws T { 121 120 updateForce(); 122 try { 123 return new String(data, "utf-8"); 124 } catch (UnsupportedEncodingException e){ 125 e.printStackTrace(); 126 return ""; 127 } 121 return new String(data, Utils.UTF_8); 128 122 } 129 123 … … 144 138 */ 145 139 public String getDataString() throws T { 146 try { 147 return new String(getData(), "utf-8"); 148 } catch(UnsupportedEncodingException e){ 149 e.printStackTrace(); 150 return ""; 151 } 140 return new String(getData(), Utils.UTF_8); 152 141 } 153 142 -
trunk/src/org/openstreetmap/josm/io/GeoJSONExporter.java
r6070 r6552 29 29 if (layer instanceof OsmDataLayer) { 30 30 String json = new GeoJSONWriter((OsmDataLayer) layer).write(); 31 Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));31 Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Utils.UTF_8)); 32 32 try { 33 33 out.write(json); -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r6380 r6552 8 8 import java.io.OutputStreamWriter; 9 9 import java.io.PrintWriter; 10 import java.io.UnsupportedEncodingException;11 10 import java.util.Collection; 12 11 import java.util.Map; … … 24 23 import org.openstreetmap.josm.data.gpx.IWithAttributes; 25 24 import org.openstreetmap.josm.data.gpx.WayPoint; 25 import org.openstreetmap.josm.tools.Utils; 26 26 27 27 /** … … 34 34 } 35 35 36 public GpxWriter(OutputStream out) throws UnsupportedEncodingException{37 super(new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, "UTF-8"))));36 public GpxWriter(OutputStream out) { 37 super(new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, Utils.UTF_8)))); 38 38 } 39 39 -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r6349 r6552 627 627 // even if there is no payload. 628 628 if (requestBody != null) { 629 BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"));629 BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, Utils.UTF_8)); 630 630 try { 631 631 bwr.write(requestBody); -
trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java
r6380 r6552 8 8 import java.io.InputStreamReader; 9 9 import java.io.StringReader; 10 import java.io.UnsupportedEncodingException;11 10 12 11 import javax.xml.parsers.ParserConfigurationException; … … 19 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 20 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 import org.openstreetmap.josm.tools.Utils; 21 21 import org.xml.sax.Attributes; 22 22 import org.xml.sax.InputSource; … … 105 105 * 106 106 * @param source the input stream with the changeset content as XML document. Must not be null. 107 * @throws UnsupportedEncodingException if {@code UTF-8} charset is missing108 107 * @throws IllegalArgumentException if source is {@code null}. 109 108 */ 110 public OsmChangesetContentParser(InputStream source) throws UnsupportedEncodingException{109 public OsmChangesetContentParser(InputStream source) { 111 110 CheckParameterUtil.ensureParameterNotNull(source, "source"); 112 this.source = new InputSource(new InputStreamReader(source, "UTF-8"));111 this.source = new InputSource(new InputStreamReader(source, Utils.UTF_8)); 113 112 } 114 113 -
trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java
r6362 r6552 18 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 19 19 import org.openstreetmap.josm.tools.DateUtils; 20 import org.openstreetmap.josm.tools.Utils; 20 21 import org.xml.sax.Attributes; 21 22 import org.xml.sax.InputSource; … … 214 215 progressMonitor.beginTask(""); 215 216 progressMonitor.indeterminateSubTask(tr("Parsing list of changesets...")); 216 InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8"));217 InputSource inputSource = new InputSource(new InputStreamReader(source, Utils.UTF_8)); 217 218 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, parser.new Parser()); 218 219 return parser.getChangesets(); -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r6380 r6552 22 22 import org.openstreetmap.josm.io.auth.CredentialsManager; 23 23 import org.openstreetmap.josm.tools.Base64; 24 import org.openstreetmap.josm.tools.Utils; 24 25 25 26 /** … … 73 74 */ 74 75 protected void addBasicAuthorizationHeader(HttpURLConnection con) throws OsmTransferException { 75 CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();76 CharsetEncoder encoder = Utils.UTF_8.newEncoder(); 76 77 CredentialsAgentResponse response; 77 78 String token; -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r5926 r6552 69 69 // create outputstream and wrap it with gzip or bzip, if necessary 70 70 OutputStream out = getOutputStream(file); 71 Writer writer = new OutputStreamWriter(out, "UTF-8");71 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 72 72 73 73 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion()); -
trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java
r6380 r6552 16 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 17 17 import org.openstreetmap.josm.tools.CheckParameterUtil; 18 import org.openstreetmap.josm.tools.Utils; 18 19 import org.xml.sax.Attributes; 19 20 import org.xml.sax.InputSource; … … 80 81 */ 81 82 public HistoryDataSet parse(ProgressMonitor progressMonitor) throws SAXException, IOException { 82 InputSource inputSource = new InputSource(new InputStreamReader(in, "UTF-8"));83 InputSource inputSource = new InputSource(new InputStreamReader(in, Utils.UTF_8)); 83 84 progressMonitor.beginTask(tr("Parsing OSM history data ...")); 84 85 try { -
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r6362 r6552 6 6 7 7 import java.io.InputStream; 8 import java.io.UnsupportedEncodingException;9 8 import java.text.MessageFormat; 10 9 import java.util.ArrayList; … … 185 184 ChangesetDataSet ds = parser.parse(monitor.createSubTaskMonitor(1, true)); 186 185 return ds; 187 } catch(UnsupportedEncodingException e) {188 throw new OsmTransferException(e);189 186 } catch(OsmDataParsingException e) { 190 187 throw new OsmTransferException(e); -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r6310 r6552 21 21 import org.openstreetmap.josm.io.MirroredInputStream; 22 22 import org.openstreetmap.josm.io.UTFInputStreamReader; 23 import org.openstreetmap.josm.tools.Utils; 23 24 import org.xml.sax.Attributes; 24 25 import org.xml.sax.InputSource; -
trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionExporter.java
r6150 r6552 17 17 import java.io.OutputStreamWriter; 18 18 import java.io.PrintWriter; 19 import java.io.UnsupportedEncodingException;20 19 import java.io.Writer; 21 20 import java.net.MalformedURLException; … … 39 38 import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport; 40 39 import org.openstreetmap.josm.tools.GBC; 40 import org.openstreetmap.josm.tools.Utils; 41 41 import org.w3c.dom.Element; 42 42 … … 180 180 181 181 protected void addDataFile(OutputStream out) throws IOException { 182 Writer writer = null; 183 try { 184 writer = new OutputStreamWriter(out, "UTF-8"); 185 } catch (UnsupportedEncodingException e) { 186 throw new RuntimeException(e); 187 } 182 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 188 183 GpxWriter w = new GpxWriter(new PrintWriter(writer)); 189 184 w.write(layer.data); -
trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java
r5874 r6552 8 8 import java.io.OutputStreamWriter; 9 9 import java.io.PrintWriter; 10 import java.io.UnsupportedEncodingException;11 10 import java.io.Writer; 12 11 import java.util.Collection; … … 18 17 import javax.swing.SwingConstants; 19 18 19 import org.openstreetmap.josm.tools.Utils; 20 20 import org.w3c.dom.Element; 21 21 … … 86 86 87 87 protected void addDataFile(OutputStream out) throws IOException { 88 Writer writer = null; 89 try { 90 writer = new OutputStreamWriter(out, "UTF-8"); 91 } catch (UnsupportedEncodingException e) { 92 throw new RuntimeException(e); 93 } 88 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 94 89 MarkerWriter w = new MarkerWriter(new PrintWriter(writer)); 95 90 w.write(layer); -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java
r6084 r6552 17 17 import java.io.OutputStreamWriter; 18 18 import java.io.PrintWriter; 19 import java.io.UnsupportedEncodingException;20 19 import java.io.Writer; 21 20 import java.net.MalformedURLException; … … 34 33 import javax.swing.SwingConstants; 35 34 35 import org.openstreetmap.josm.tools.Utils; 36 36 import org.w3c.dom.Element; 37 37 … … 214 214 215 215 protected void addDataFile(OutputStream out) throws IOException { 216 Writer writer = null; 217 try { 218 writer = new OutputStreamWriter(out, "UTF-8"); 219 } catch (UnsupportedEncodingException e) { 220 throw new RuntimeException(e); 221 } 216 Writer writer = new OutputStreamWriter(out, Utils.UTF_8); 222 217 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion()); 223 218 layer.data.getReadLock().lock(); -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r6271 r6552 225 225 public void writeJos(Document doc, OutputStream out) throws IOException { 226 226 try { 227 OutputStreamWriter writer = new OutputStreamWriter(out, "utf-8");227 OutputStreamWriter writer = new OutputStreamWriter(out, Utils.UTF_8); 228 228 writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); 229 229 TransformerFactory transfac = TransformerFactory.newInstance(); -
trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java
r6296 r6552 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins; 3 4 import org.openstreetmap.josm.tools.Utils; 3 5 4 6 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 11 import java.io.InputStream; 10 12 import java.io.InputStreamReader; 11 import java.io.UnsupportedEncodingException;12 13 import java.util.LinkedList; 13 14 import java.util.List; … … 35 36 try { 36 37 return new PluginInformation( 37 new ByteArrayInputStream(manifest.getBytes( "utf-8")),38 new ByteArrayInputStream(manifest.getBytes(Utils.UTF_8)), 38 39 name.substring(0, name.length() - 4), 39 40 url 40 41 ); 41 } catch(UnsupportedEncodingException e) {42 throw new PluginListParseException(tr("Failed to create plugin information from manifest for plugin ''{0}''", name), e);43 42 } catch (PluginException e) { 44 43 throw new PluginListParseException(tr("Failed to create plugin information from manifest for plugin ''{0}''", name), e); … … 61 60 BufferedReader r = null; 62 61 try { 63 r = new BufferedReader(new InputStreamReader(in, "utf-8"));62 r = new BufferedReader(new InputStreamReader(in, Utils.UTF_8)); 64 63 String name = null; 65 64 String url = null; -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r6257 r6552 17 17 import java.io.OutputStreamWriter; 18 18 import java.io.PrintWriter; 19 import java.io.UnsupportedEncodingException;20 19 import java.net.HttpURLConnection; 21 20 import java.net.MalformedURLException; … … 174 173 connection.setRequestProperty("Accept-Charset", "utf-8"); 175 174 } 176 in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));175 in = new BufferedReader(new InputStreamReader(connection.getInputStream(), Utils.UTF_8)); 177 176 StringBuilder sb = new StringBuilder(); 178 177 while ((line = in.readLine()) != null) { … … 207 206 try { 208 207 String line; 209 err = new BufferedReader(new InputStreamReader(errStream, "UTF-8"));208 err = new BufferedReader(new InputStreamReader(errStream, Utils.UTF_8)); 210 209 while ((line = err.readLine()) != null) { 211 210 sb.append(line).append("\n"); … … 319 318 File cacheFile = createSiteCacheFile(pluginDir, site, CacheType.PLUGIN_LIST); 320 319 getProgressMonitor().subTask(tr("Writing plugin list to local cache ''{0}''", cacheFile.toString())); 321 writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(cacheFile), "utf-8"));320 writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(cacheFile), Utils.UTF_8)); 322 321 writer.write(list); 323 322 } catch(IOException e) { … … 363 362 try { 364 363 getProgressMonitor().subTask(tr("Parsing plugin list from site ''{0}''", site)); 365 InputStream in = new ByteArrayInputStream(doc.getBytes( "UTF-8"));364 InputStream in = new ByteArrayInputStream(doc.getBytes(Utils.UTF_8)); 366 365 List<PluginInformation> pis = new PluginListParser().parse(in); 367 366 availablePlugins.addAll(filterDeprecatedPlugins(pis)); 368 } catch (UnsupportedEncodingException e) {369 Main.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString()));370 e.printStackTrace();371 367 } catch (PluginListParseException e) { 372 368 Main.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString())); -
trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
r6380 r6552 194 194 ByteArrayOutputStream out = new ByteArrayOutputStream(); 195 195 GZIPOutputStream gzip = new GZIPOutputStream(out); 196 gzip.write(debugText.getBytes( "UTF-8"));196 gzip.write(debugText.getBytes(Utils.UTF_8)); 197 197 Utils.close(gzip); 198 198 -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r6380 r6552 548 548 if(rval != val) /* file corrupt */ 549 549 return false; 550 enstrings[i] = new String(str, 0, val, "utf-8");550 enstrings[i] = new String(str, 0, val, Utils.UTF_8); 551 551 } 552 552 for(int i = 0; i < trnum; ++i) … … 562 562 if(rval != val) /* file corrupt */ 563 563 return false; 564 trstrings[i] = new String(str, 0, val, "utf-8");564 trstrings[i] = new String(str, 0, val, Utils.UTF_8); 565 565 } 566 566 if(trnum > 0 && !p.containsKey(enstrings[0])) { … … 600 600 if(val != enval) /* file corrupt */ 601 601 return false; 602 String enstr = new String(str, 0, enval, "utf-8");602 String enstr = new String(str, 0, enval, Utils.UTF_8); 603 603 if(trval != 0) 604 604 { … … 606 606 if(val != trval) /* file corrupt */ 607 607 return false; 608 String trstr = new String(str, 0, trval, "utf-8");608 String trstr = new String(str, 0, trval, Utils.UTF_8); 609 609 if(!s.containsKey(enstr)) 610 610 s.put(enstr, trstr); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6538 r6552 23 23 import java.io.InputStreamReader; 24 24 import java.io.OutputStream; 25 import java.io.UnsupportedEncodingException;26 25 import java.net.HttpURLConnection; 27 26 import java.net.URL; 28 27 import java.net.URLConnection; 29 28 import java.nio.channels.FileChannel; 29 import java.nio.charset.Charset; 30 30 import java.security.MessageDigest; 31 31 import java.security.NoSuchAlgorithmException; … … 56 56 } 57 57 58 /** 59 * UTF-8 (UCS Transformation Format—8-bit). 60 * 61 * <p>Every implementation of the Java platform is required to support UTF-8 (see {@link Charset}).</p> 62 */ 63 public static final Charset UTF_8 = Charset.forName("UTF-8"); 64 58 65 public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) { 59 66 for (T item : collection) { … … 436 443 */ 437 444 public static String md5Hex(String data) { 438 byte[] byteData = null; 439 try { 440 byteData = data.getBytes("UTF-8"); 441 } catch (UnsupportedEncodingException e) { 442 throw new RuntimeException(); 443 } 445 byte[] byteData = data.getBytes(UTF_8); 444 446 MessageDigest md = null; 445 447 try { … … 707 709 */ 708 710 public static BufferedReader openURLReaderAndDecompress(final URL url, final boolean decompress) throws IOException { 709 return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), "utf-8"));711 return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), UTF_8)); 710 712 } 711 713 -
trunk/test/unit/org/openstreetmap/josm/io/OsmChangesetContentParserTest.groovy
r2690 r6552 2 2 package org.openstreetmap.josm.io; 3 3 4 import org.junit.Test 4 import org.junit.Test 5 import org.openstreetmap.josm.tools.Utils 5 6 6 7 import static org.junit.Assert.*; … … 42 43 43 44 // should be OK 44 parser = new OsmChangesetContentParser(new ByteArrayInputStream(doc.getBytes( "UTF-8")))45 parser = new OsmChangesetContentParser(new ByteArrayInputStream(doc.getBytes(Utils.UTF_8))) 45 46 parser.parse null 46 47 47 48 // should be OK 48 parser = new OsmChangesetContentParser(new ByteArrayInputStream(doc.getBytes( "UTF-8")))49 parser = new OsmChangesetContentParser(new ByteArrayInputStream(doc.getBytes(Utils.UTF_8))) 49 50 parser.parse NullProgressMonitor.INSTANCE 50 51
Note:
See TracChangeset
for help on using the changeset viewer.