Author: echatellier Date: 2010-05-11 16:42:58 +0200 (Tue, 11 May 2010) New Revision: 1860 Url: http://nuiton.org/repositories/revision/nuiton-utils/1860 Log: fix #601 : file.toURI seam to encode better file path Modified: trunk/src/main/java/org/nuiton/util/Resource.java Modified: trunk/src/main/java/org/nuiton/util/Resource.java =================================================================== --- trunk/src/main/java/org/nuiton/util/Resource.java 2010-05-11 11:53:05 UTC (rev 1859) +++ trunk/src/main/java/org/nuiton/util/Resource.java 2010-05-11 14:42:58 UTC (rev 1860) @@ -328,12 +328,28 @@ } for (URL urlFile : arrayURL) { - String fileName = urlFile.getFile(); + // EC-20100510 this cause wrong accent encoding + //String fileName = urlFile.getFile(); + String fileName = null; + try { + fileName = urlFile.toURI().getPath(); + } + catch (Exception e) { + if (log.isWarnEnabled()) { + log.warn(e); + } + // warning, this can cause wrong encoding !!! + fileName = urlFile.getFile(); + } + // TODO deal with encoding in windows, this is very durty, but it // works... File file = new File(fileName.replaceAll("%20", " ")); if (!file.exists()) { // this case should not appear + if (log.isDebugEnabled()) { + log.debug("Can't find file " + file + " (" + fileName + ")"); + } continue; } if (isJar(fileName)) {
participants (1)
-
echatellier@users.nuiton.org