Logo Search packages:      
Sourcecode: octave-java version File versions  Download package

static boolean org::octave::ClassHelper::removeClassPath ( String  name ) throws Exception [inline, static]
Parameters:
nameString - path to remove from classpath.
Returns:
boolean - true if the given path existed in the classpath before it was removed.
Exceptions:
Exception

Definition at line 60 of file ClassHelper.java.

   {
      boolean found = false;
      java.io.File f = new java.io.File ( name );
      java.net.URL urlToRemove = f.toURI ().toURL ();
      // save urls in current class path
      java.net.URL[] urls = loader.getURLs ();

      // create a completely new class loader because java.net.URLClassLoader has no removeClassPath() method
      ClassLoader l = ClassHelper.class.getClassLoader ();
      loader = ( l instanceof OctClassLoader ? ( OctClassLoader ) l :
                 new OctClassLoader ( l ) );

      // add the previous urls back, except for the one
      for ( int i = 0; i < urls.length; i++ )
      {
         java.net.URL url = urls[i];
         if ( !url.equals ( urlToRemove ) )
         {
            loader.addURL ( url );
         }
         else
         {
            // path to remove
            found = true;
         }
      }

      return ( found );
   }

Generated by  Doxygen 1.6.0   Back to index