From 8582787ca677bf6978b23a8d6c9741f3b7842179 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 8 Dec 2011 11:42:18 +0000 Subject: [PATCH] simple escape utility class for JAL-1023 patch --- src/jalview/util/Platform.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 392f1f9..ad9a9b7 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -51,4 +51,23 @@ public class Platform // TODO: determine nominal limits for most platforms. return 2046; // this is the max length for a windows NT system. } + + /** + * escape a string according to the local platform's escape character + * @param file + * @return escaped file + */ + public static String escapeString(String file) + { + StringBuffer f=new StringBuffer(); + int p=0,lastp=0; + while ((p=file.indexOf('\\',lastp))>-1) + { + f.append(file.subSequence(lastp,p)); + f.append("\\\\"); + lastp=p+1; + } + f.append(file.substring(lastp)); + return f.toString(); + } } -- 1.7.10.2