From bfc0ea779cfbbee5439a33b8ebf4161a11473786 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Tue, 5 Aug 2008 09:36:52 +0000 Subject: [PATCH] A patch from Marco Ruocco solving an issue on Windows : File.separator in Windows system is "\", that is, also, the first character of an escape sequence. So the replaceAll method expects another char after that. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@682652 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/base/org/ofbiz/base/util/FileUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/framework/base/src/base/org/ofbiz/base/util/FileUtil.java b/framework/base/src/base/org/ofbiz/base/util/FileUtil.java index ed0b421044..244ba7b4a1 100644 --- a/framework/base/src/base/org/ofbiz/base/util/FileUtil.java +++ b/framework/base/src/base/org/ofbiz/base/util/FileUtil.java @@ -46,12 +46,24 @@ public class FileUtil { public static final String module = FileUtil.class.getName(); + public static String escapeSeparator( String separator ) + { + if( "\\".equals( separator ) ) + { + return "\\" + separator; + } + else + { + return separator; + } + } + public static File getFile(String path) { - return new File(path.replaceAll("/+|\\\\+", File.separator)); + return new File(path.replaceAll("/+|\\\\+", escapeSeparator(File.separator))); } public static File getFile(File root, String path) { - return new File(root, path.replaceAll("/+|\\\\+", File.separator)); + return new File(root, path.replaceAll("/+|\\\\+", escapeSeparator(File.separator))); } public static void writeString(String fileName, String s) throws IOException {