I posted this to the vrml/java3d site as well
anyone have a clue?

I get a Malformed url exception when using this code from the vrml/java3d site
it goes
Malformed Url Exception 
url "./" is not a valid url


if loading a vrml object via a Reader
then the setWorldURL method is called
well, inside of this method all forward slashes are used, instead of using the
File.separator value
in the jdk

here is the code
with my comments in //note here

public void setWorldURL(URL baseURL, URL worldURL) {
        this.worldURL = worldURL;
        if (baseURL == null) {
            if (worldURL == null) { // input is from an input stream
                worldURLBaseName = new String("."+"/"); //note here, this should
be File.separator, not '/'
            } else {
                // figure out baseURL from the worldURL
                java.util.StringTokenizer stok =
                    new java.util.StringTokenizer(worldURL.toString(),
                            "/");//note here, this should be File.separator, not
'/'

                int tocount = stok.countTokens()-1;
                StringBuffer sb = new StringBuffer(80);
                for(int ji = 0; ji < tocount ; ji++) {
                    String a = stok.nextToken();
                    if((ji == 0) && (!a.equals("file:"))) {
                        sb.append(a);
                        sb.append("/");//note here, this should be
File.separator, not '/'

                        sb.append("/");//note here, this should be
File.separator, not '/'

                    } else {
                        sb.append(a);
                        sb.append("/");//note here, this should be
File.separator, not '/'
                    }
                }
                worldURLBaseName = sb.toString();
            }
        }  else {
            worldURLBaseName = baseURL.toString();
        }
        if (debug) {
            System.out.println("World URL base is \"" + worldURLBaseName +
"\"");//note here, this should be File.separator, not '\'

        }
        try {
            worldURLBase = new URL(worldURLBaseName);
            // Give Applet style security for where classes 
            // can come from. A Script must originate relative
            // to the parent URL.
            scl =
(java.net.URLClassLoader)java.security.AccessController.doPrivileged(
                new java.security.PrivilegedAction() {
                    public Object run() {
                        return new URLClassLoader( new URL[] { worldURLBase } );
                    }
                }
            );
            
        } catch (java.net.MalformedURLException murle) {
            worldURLBase = (URL)null;
            murle.printStackTrace();
        }
    }

Scott Decker
Research Scientist
Pacific Northwest National Labs
[EMAIL PROTECTED]



Scott Decker
Research Scientist
Pacific Northwest National Labs
[EMAIL PROTECTED]

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to