Changeset 7089 in josm for trunk/src/org


Ignore:
Timestamp:
2014-05-09T14:36:55+02:00 (11 years ago)
Author:
Don-vip
Message:

see #8465 - Use of new Java 7 zip constructors allowing to specify a charset for entries names

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java

    r7033 r7089  
    1414import java.net.MalformedURLException;
    1515import java.net.URL;
     16import java.nio.charset.StandardCharsets;
    1617import java.util.Enumeration;
    1718import java.util.zip.ZipEntry;
     
    169170     */
    170171    public static void unzipFileRecursively(File file, String dir) throws IOException {
    171         try (ZipFile zf = new ZipFile(file)) {
     172        try (ZipFile zf = new ZipFile(file, StandardCharsets.UTF_8)) {
    172173            Enumeration<? extends ZipEntry> es = zf.entries();
    173174            while (es.hasMoreElements()) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r7083 r7089  
    162162            File file = in.getFile();
    163163            Utils.close(in);
    164             zipFile = new ZipFile(file);
     164            zipFile = new ZipFile(file, StandardCharsets.UTF_8);
    165165            zipIcons = file;
    166166            ZipEntry zipEntry = zipFile.getEntry(zipEntryPath);
  • trunk/src/org/openstreetmap/josm/io/Compression.java

    r7033 r7089  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
    3 
    4 import org.apache.tools.bzip2.CBZip2OutputStream;
    5 import org.openstreetmap.josm.tools.Utils;
    63
    74import java.io.File;
     
    129import java.io.OutputStream;
    1310import java.net.URL;
     11import java.nio.charset.StandardCharsets;
    1412import java.util.zip.GZIPOutputStream;
    1513import java.util.zip.ZipOutputStream;
     14
     15import org.apache.tools.bzip2.CBZip2OutputStream;
     16import org.openstreetmap.josm.tools.Utils;
    1617
    1718/**
     
    103104                return new GZIPOutputStream(out);
    104105            case ZIP:
    105                 return new ZipOutputStream(out);
     106                return new ZipOutputStream(out, StandardCharsets.UTF_8);
    106107            case NONE:
    107108            default:
  • trunk/src/org/openstreetmap/josm/io/FileImporter.java

    r6882 r7089  
    88import java.io.IOException;
    99import java.io.InputStream;
     10import java.nio.charset.StandardCharsets;
    1011import java.util.List;
    1112import java.util.zip.GZIPInputStream;
     
    162163            return null;
    163164        }
    164         ZipInputStream zis = new ZipInputStream(in);
     165        ZipInputStream zis = new ZipInputStream(in, StandardCharsets.UTF_8);
    165166        // Positions the stream at the beginning of first entry
    166167        ZipEntry ze = zis.getNextEntry();
  • trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java

    r7081 r7089  
    1515import java.net.MalformedURLException;
    1616import java.net.URL;
     17import java.nio.charset.StandardCharsets;
    1718import java.util.ArrayList;
    1819import java.util.Arrays;
     
    3940    /**
    4041     * Constructs an input stream from a given filename, URL or internal resource.
    41      * 
     42     *
    4243     * @param name can be:<ul>
    4344     *  <li>relative or absolute file name</li>
     
    5455    /**
    5556     * Constructs an input stream from a given filename, URL or internal resource.
    56      * 
     57     *
    5758     * @param name can be:<ul>
    5859     *  <li>relative or absolute file name</li>
     
    7071    /**
    7172     * Constructs an input stream from a given filename, URL or internal resource.
    72      * 
     73     *
    7374     * @param name can be:<ul>
    7475     *  <li>relative or absolute file name</li>
     
    8687    /**
    8788     * Constructs an input stream from a given filename, URL or internal resource.
    88      * 
     89     *
    8990     * @param name can be:<ul>
    9091     *  <li>relative or absolute file name</li>
     
    103104    /**
    104105     * Constructs an input stream from a given filename, URL or internal resource.
    105      * 
     106     *
    106107     * @param name can be:<ul>
    107108     *  <li>relative or absolute file name</li>
     
    121122    /**
    122123     * Constructs an input stream from a given filename, URL or internal resource.
    123      * 
     124     *
    124125     * @param name can be:<ul>
    125126     *  <li>relative or absolute file name</li>
     
    200201        Pair<String, InputStream> res = null;
    201202        try {
    202             ZipFile zipFile = new ZipFile(file);
     203            ZipFile zipFile = new ZipFile(file, StandardCharsets.UTF_8);
    203204            ZipEntry resentry = null;
    204205            Enumeration<? extends ZipEntry> entries = zipFile.entries();
     
    239240        cleanup(name, null);
    240241    }
    241    
     242
    242243    public static void cleanup(String name, String destDir) {
    243244        URL url;
     
    349350     * <p>
    350351     * This can causes problems when downloading from certain GitHub URLs.
    351      * 
     352     *
    352353     * @param downloadUrl The resource URL to download
    353354     * @param httpAccept The accepted MIME types sent in the HTTP Accept header. Can be {@code null}
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r7083 r7089  
    1313import java.net.URI;
    1414import java.net.URISyntaxException;
     15import java.nio.charset.StandardCharsets;
    1516import java.util.ArrayList;
    1617import java.util.Collections;
     
    559560        if (zip) {
    560561            try {
    561                 zipFile = new ZipFile(sessionFile);
     562                zipFile = new ZipFile(sessionFile, StandardCharsets.UTF_8);
    562563                return getZipInputStream(zipFile);
    563564            } catch (ZipException ze) {
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r7082 r7089  
    249249    public void write(OutputStream out) throws IOException {
    250250        if (zip) {
    251             zipOut = new ZipOutputStream(new BufferedOutputStream(out));
     251            zipOut = new ZipOutputStream(new BufferedOutputStream(out), StandardCharsets.UTF_8);
    252252        }
    253253        Document doc = createJosDocument(); // as side effect, files may be added to zipOut
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7082 r7089  
    598598
    599599    private static ImageResource getIfAvailableZip(String fullName, File archive, String inArchiveDir, ImageType type) {
    600         try (ZipFile zipFile = new ZipFile(archive)) {
     600        try (ZipFile zipFile = new ZipFile(archive, StandardCharsets.UTF_8)) {
    601601            if (inArchiveDir == null || ".".equals(inArchiveDir)) {
    602602                inArchiveDir = "";
Note: See TracChangeset for help on using the changeset viewer.