@Test (expected = NullPointerException.class) public void testGetNullJarFile () { JarUtils.getJarFileOfClass(null); }
public static File getJarFileOfClass (Class<?> cls) { if (cls == null) { throw new NullPointerException("class cannot be null."); } String classResource = cls.getName().replace('.', '/') + ".class"; URL location = cls.getResource('/' + cls.getName().replace('.', '/') + ".class"); String jarPath = location.getPath(); return pathToFile(jarPath, classResource); }
JarUtils { public static File getJarFileOfClass (Class<?> cls) { if (cls == null) { throw new NullPointerException("class cannot be null."); } String classResource = cls.getName().replace('.', '/') + ".class"; URL location = cls.getResource('/' + cls.getName().replace('.', '/') + ".class"); String jarPath = location.getPath(); return pathToFile(jarPath, classResource); } }
JarUtils { public static File getJarFileOfClass (Class<?> cls) { if (cls == null) { throw new NullPointerException("class cannot be null."); } String classResource = cls.getName().replace('.', '/') + ".class"; URL location = cls.getResource('/' + cls.getName().replace('.', '/') + ".class"); String jarPath = location.getPath(); return pathToFile(jarPath, classResource); } protected  JarUtils(); }
JarUtils { public static File getJarFileOfClass (Class<?> cls) { if (cls == null) { throw new NullPointerException("class cannot be null."); } String classResource = cls.getName().replace('.', '/') + ".class"; URL location = cls.getResource('/' + cls.getName().replace('.', '/') + ".class"); String jarPath = location.getPath(); return pathToFile(jarPath, classResource); } protected  JarUtils(); static File getJarFileOfClass(Class<?> cls); static String getJarPath(Class<?> cls); }
JarUtils { public static File getJarFileOfClass (Class<?> cls) { if (cls == null) { throw new NullPointerException("class cannot be null."); } String classResource = cls.getName().replace('.', '/') + ".class"; URL location = cls.getResource('/' + cls.getName().replace('.', '/') + ".class"); String jarPath = location.getPath(); return pathToFile(jarPath, classResource); } protected  JarUtils(); static File getJarFileOfClass(Class<?> cls); static String getJarPath(Class<?> cls);  }