Author: ruschein
Date: 2010-07-09 15:06:26 -0700 (Fri, 09 Jul 2010)
New Revision: 20874

Modified:
   cytoscape/trunk/src/cytoscape/CytoscapeInit.java
Log:
Fixed opening session files that contaimn percent files.

Modified: cytoscape/trunk/src/cytoscape/CytoscapeInit.java
===================================================================
--- cytoscape/trunk/src/cytoscape/CytoscapeInit.java    2010-07-09 20:35:32 UTC 
(rev 20873)
+++ cytoscape/trunk/src/cytoscape/CytoscapeInit.java    2010-07-09 22:06:26 UTC 
(rev 20874)
@@ -454,8 +454,9 @@
                                } else {
                                        
Cytoscape.setCurrentSessionFileName(sessionFile);
 
-                                       File shortName = new File(sessionFile);
-                                       URL sessionURL = shortName.toURL();
+                                       final File shortName = new 
File(sessionFile);
+                                       final String absolutePath = 
shortName.getAbsolutePath();
+                                       final URL sessionURL = new 
URL("file://" + escapePercentSign(absolutePath));
                                        reader = new 
CytoscapeSessionReader(sessionURL);
                                        sessionName = shortName.getName();
                                }
@@ -477,6 +478,21 @@
                return false;
        }
 
+       /**
+        *  @return 
+        */
+       private String escapePercentSign(final String rawString) {
+               final StringBuilder cookedString = new 
StringBuilder(rawString.length());
+               for (int i = 0; i < rawString.length(); ++i) {
+                       final char ch = rawString.charAt(i);
+                       if (ch == '%')
+                               cookedString.append("%25");
+                       else
+                               cookedString.append(ch);
+               }
+               return cookedString.toString();
+       }
+
        private static void initProperties() {
                if (properties == null) {
                        properties = new Properties();

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to