[Schmitzm-commits] r1366 - trunk/src/schmitzm/io

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 13 10:25:52 CET 2011


Author: alfonx
Date: 2011-01-13 10:25:51 +0100 (Thu, 13 Jan 2011)
New Revision: 1366

Modified:
   trunk/src/schmitzm/io/IOUtil.java
Log:
Better cleaning of URL encoded filenames (cleanfilename-method)

Modified: trunk/src/schmitzm/io/IOUtil.java
===================================================================
--- trunk/src/schmitzm/io/IOUtil.java	2011-01-12 15:23:59 UTC (rev 1365)
+++ trunk/src/schmitzm/io/IOUtil.java	2011-01-13 09:25:51 UTC (rev 1366)
@@ -911,6 +911,21 @@
 	public static String cleanFilename(String filename) {
 
 		final String orig = filename;
+
+		// When getting URL encoded filenames, the spaces might already be
+		// converted to
+		try {
+			URL asUrl = new URL("file://localhost/" + filename);
+			filename = DataUtilities.urlToFile(asUrl).getName();
+//			filename = asUrl.getFile();
+//			if (filename.startsWith("/"))
+//				filename = filename.substring(1);
+		} catch (Exception e) {
+//			System.out.println(e);
+		}
+
+		filename = filename.replace(" ", "_");
+
 		filename = filename.toLowerCase();
 		filename = filename.replace(" ", "_");
 



More information about the Schmitzm-commits mailing list