Ignore:
Timestamp:
2014-05-09T05:32:37+02:00 (10 years ago)
Author:
Don-vip
Message:

see #8465 - replace Utils.UTF_8 by StandardCharsets.UTF_8, new in Java 7

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r7060 r7082  
    1212import java.net.URL;
    1313import java.nio.ByteBuffer;
     14import java.nio.charset.StandardCharsets;
    1415import java.util.zip.GZIPOutputStream;
    1516
     
    4243    private static int exceptionCounter = 0;
    4344    private static boolean suppressExceptionDialogs = false;
    44    
     45
    4546    private static class BugReporterThread extends Thread {
    46        
     47
    4748        final Throwable e;
    48        
     49
    4950        public BugReporterThread(Throwable t) {
    5051            super("Bug Reporter");
     
    139140        }
    140141    }
    141    
     142
    142143    private static void askForBugReport(final Throwable e) {
    143144        try {
     
    215216            GZIPOutputStream gzip = new GZIPOutputStream(out)
    216217        ) {
    217             gzip.write(debugText.getBytes(Utils.UTF_8));
     218            gzip.write(debugText.getBytes(StandardCharsets.UTF_8));
    218219            gzip.finish();
    219220
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r7033 r7082  
    88import java.io.InputStream;
    99import java.net.URL;
     10import java.nio.charset.StandardCharsets;
    1011import java.text.MessageFormat;
    1112import java.util.ArrayList;
     
    532533                        if(rval != val) /* file corrupt */
    533534                            return false;
    534                         enstrings[i] = new String(str, 0, val, Utils.UTF_8);
     535                        enstrings[i] = new String(str, 0, val, StandardCharsets.UTF_8);
    535536                    }
    536537                    for(int i = 0; i < trnum; ++i)
     
    546547                        if(rval != val) /* file corrupt */
    547548                            return false;
    548                         trstrings[i] = new String(str, 0, val, Utils.UTF_8);
     549                        trstrings[i] = new String(str, 0, val, StandardCharsets.UTF_8);
    549550                    }
    550551                    if(trnum > 0 && !p.containsKey(enstrings[0])) {
     
    572573                        if(trval != 0xFFFF) /* files do not match */
    573574                            return false;
    574                     }
    575                     else
    576                     {
    577                         if(enval > str.length) {
     575                    } else {
     576                        if (enval > str.length) {
    578577                            str = new byte[enval];
    579578                        }
    580                         if(trval > str.length) {
     579                        if (trval > str.length) {
    581580                            str = new byte[trval];
    582581                        }
     
    584583                        if(val != enval) /* file corrupt */
    585584                            return false;
    586                         String enstr = new String(str, 0, enval, Utils.UTF_8);
    587                         if(trval != 0)
    588                         {
     585                        String enstr = new String(str, 0, enval, StandardCharsets.UTF_8);
     586                        if (trval != 0) {
    589587                            val = trs.read(str, 0, trval);
    590588                            if(val != trval) /* file corrupt */
    591589                                return false;
    592                             String trstr = new String(str, 0, trval, Utils.UTF_8);
     590                            String trstr = new String(str, 0, trval, StandardCharsets.UTF_8);
    593591                            if(!s.containsKey(enstr))
    594592                                s.put(enstr, trstr);
     
    598596            }
    599597        }
    600         catch(IOException e)
    601         {
     598        catch (IOException e) {
    602599            return false;
    603600        }
    604         if(!s.isEmpty())
    605         {
     601        if (!s.isEmpty()) {
    606602            strings = s;
    607603            pstrings = p;
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7075 r7082  
    2424import java.net.URLDecoder;
    2525import java.net.URLEncoder;
     26import java.nio.charset.StandardCharsets;
    2627import java.util.ArrayList;
    2728import java.util.Arrays;
     
    537538                } else {
    538539                    try {
    539                         bytes = URLDecoder.decode(data, "UTF-8").getBytes(Utils.UTF_8);
     540                        bytes = URLDecoder.decode(data, "UTF-8").getBytes(StandardCharsets.UTF_8);
    540541                    } catch (IllegalArgumentException ex) {
    541542                        Main.warn("Unable to decode URL data part: "+ex.getMessage() + " (" + data + ")");
     
    544545                }
    545546                if (mediatype != null && mediatype.contains("image/svg+xml")) {
    546                     String s = new String(bytes, Utils.UTF_8);
     547                    String s = new String(bytes, StandardCharsets.UTF_8);
    547548                    URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8"));
    548549                    SVGDiagram svg = getSvgUniverse().getDiagram(uri);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r7075 r7082  
    1515import java.net.URI;
    1616import java.net.URISyntaxException;
     17import java.nio.charset.StandardCharsets;
    1718import java.util.Arrays;
    1819
     
    201202                // Try lsb_release (only available on LSB-compliant Linux systems, see https://www.linuxbase.org/lsb-cert/productdir.php?by_prod )
    202203                Process p = Runtime.getRuntime().exec("lsb_release -ds");
    203                 try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), Utils.UTF_8))) {
     204                try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) {
    204205                    String line = Utils.strip(input.readLine());
    205206                    if (line != null && !line.isEmpty()) {
     
    284285                File file = new File(path);
    285286                if (file.exists()) {
    286                     try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF_8))) {
     287                    try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
    287288                        String id = null;
    288289                        String release = null;
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7037 r7082  
    2727import java.net.URLConnection;
    2828import java.net.URLEncoder;
    29 import java.nio.charset.Charset;
     29import java.nio.charset.StandardCharsets;
    3030import java.nio.file.Files;
    3131import java.nio.file.Path;
     
    6363    }
    6464
    65     /**
    66      * UTF-8 (UCS Transformation Format—8-bit).
    67      *
    68      * <p>Every implementation of the Java platform is required to support UTF-8 (see {@link Charset}).</p>
    69      */
    70     public static final Charset UTF_8 = Charset.forName("UTF-8");
    71 
    7265    private static final int MILLIS_OF_SECOND = 1000;
    7366    private static final int MILLIS_OF_MINUTE = 60000;
     
    476469     */
    477470    public static String md5Hex(String data) {
    478         byte[] byteData = data.getBytes(UTF_8);
     471        byte[] byteData = data.getBytes(StandardCharsets.UTF_8);
    479472        MessageDigest md = null;
    480473        try {
     
    726719     */
    727720    public static BufferedReader openURLReaderAndDecompress(final URL url, final boolean decompress) throws IOException {
    728         return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), UTF_8));
     721        return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), StandardCharsets.UTF_8));
    729722    }
    730723
     
    801794        }
    802795        Process p = new ProcessBuilder(command).start();
    803         try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))) {
     796        try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8))) {
    804797            StringBuilder all = null;
    805798            String line;
Note: See TracChangeset for help on using the changeset viewer.