[Schmitzm-commits] r1054 - trunk/src/schmitzm/io
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Sep 23 19:37:49 CEST 2010
Author: alfonx
Date: 2010-09-23 19:37:48 +0200 (Thu, 23 Sep 2010)
New Revision: 1054
Modified:
trunk/src/schmitzm/io/IOUtil.java
Log:
Improved Path readability under windows by adding to IOUtil:
/**
* Bereinigt Pfadangaben, z.b. "C:\Programme" zu "C:\\Programme" und
* "Eigene%20Dateien" zu "Eigene Dateien"
*/
public static String escapePath(String path) {
if (path == null) return "";
path = path.replace("\\", "\\\\");
path = path.replace("%20", " ");
return path;
}
/**
* Liefert eine bereinigt Absolute-Pfadangaben, z.b. "C:\Programme" zu "C:\\Programme" und
* "Eigene%20Dateien" zu "Eigene Dateien"
*/
public static String escapePath(File file) {
if (file == null) return "";
return escapePath(file.getAbsolutePath());
}
Modified: trunk/src/schmitzm/io/IOUtil.java
===================================================================
--- trunk/src/schmitzm/io/IOUtil.java 2010-09-23 16:20:26 UTC (rev 1053)
+++ trunk/src/schmitzm/io/IOUtil.java 2010-09-23 17:37:48 UTC (rev 1054)
@@ -208,8 +208,7 @@
*
* @return A new {@link URL} with new extension.
*
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Tzeggai</a>
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*
*/
public static URL changeUrlExt(final URL url, final String postfix)
@@ -233,8 +232,7 @@
* zusammengesetzt. Falls eine Verkuerzung nicht moeglich ist, wird eine
* {@link MalformedURLException} geworfen
*
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Tzeggai</a>
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*
*
*/
@@ -589,8 +587,7 @@
*
* @param url
*
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Tzeggai</a>
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
public static File urlToFile(URL url) {
// LOGGER.debug("\nconverting " + url.toString() + " to ");
@@ -651,14 +648,13 @@
* This method does some extra checks and returns a valid
* {@link File}
*
- * @see
- * <code>http://rationalpi.wordpress.com/2007/01/26/javaiotmpdir-inconsitency/</code>
+ * @see <code>http://rationalpi.wordpress.com/2007/01/26/javaiotmpdir-inconsitency/</code>
*/
public static File getTempDir() {
if (tempDir == null) {
- String tempPath = System.getProperty("java.io.tmpdir", System
- .getenv("TEMP"));
+ String tempPath = System.getProperty("java.io.tmpdir",
+ System.getenv("TEMP"));
if (tempPath == null || tempPath.isEmpty()
|| !new File(tempPath).exists()) {
@@ -774,4 +770,26 @@
return false;
}
}
+
+
+ /**
+ * Bereinigt Pfadangaben, z.b. "C:\Programme" zu "C:\\Programme" und
+ * "Eigene%20Dateien" zu "Eigene Dateien"
+ */
+
+ public static String escapePath(String path) {
+ if (path == null) return "";
+ path = path.replace("\\", "\\\\");
+ path = path.replace("%20", " ");
+ return path;
+ }
+
+ /**
+ * Liefert eine bereinigt Absolute-Pfadangaben, z.b. "C:\Programme" zu "C:\\Programme" und
+ * "Eigene%20Dateien" zu "Eigene Dateien"
+ */
+ public static String escapePath(File file) {
+ if (file == null) return "";
+ return escapePath(file.getAbsolutePath());
+ }
}
More information about the Schmitzm-commits
mailing list