Java ClassPath Get getClassPath(File dir)

Here you can find the source of getClassPath(File dir)

Description

get Class Path

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
    public static URL[] getClassPath(File dir) 

Method Source Code

//package com.java2s;
/**/* w  w w  .  ja  va2 s .  co m*/
* Copyright (c) 2004-2005 jManage.org
*
* This is a free software; you can redistribute it and/or
* modify it under the terms of the license at
* http://www.jmanage.org.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import java.net.URL;
import java.net.MalformedURLException;
import java.io.File;

public class Main {
    @SuppressWarnings("deprecation")
    public static URL[] getClassPath(File dir) {
        assert dir.isDirectory();
        try {
            File[] files = dir.listFiles();
            URL[] urls = new URL[files.length];
            for (int i = 0; i < files.length; i++) {
                urls[i] = files[i].toURL();
            }
            return urls;
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getClassPath(Class c)
  2. getClassPath(Class clazz)
  3. getClasspath(ClassLoader classLoader)
  4. getClassPath(ClassLoader loader)
  5. getClasspath(ClassLoader loader)
  6. getClassPath(Object obj, boolean bOnlyPath)
  7. getClassPath(String packageName, String name)
  8. getClassPathAsString(ClassLoader classLoader)
  9. getClasspathDir(Class klass)