From: jprocter Date: Thu, 8 Dec 2011 11:42:18 +0000 (+0000) Subject: simple escape utility class for JAL-1023 patch X-Git-Tag: Archived_Release_2_7~13^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8582787ca677bf6978b23a8d6c9741f3b7842179;p=jalview.git simple escape utility class for JAL-1023 patch --- 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(); + } }