Load properties from classpath.

@param clasz
Class in the same package as the properties file - Cannot be <code>null</code>.
@param filename
Name of the properties file (without path) - Cannot be <code>null</code>.

@return Properties.
514532
public static Properties loadProperties(final Class<?> clasz, final String filename) {
        checkNotNull("clasz", clasz);
        checkNotNull("filename", filename);

        final String path = getPackagePath(clasz);
        final String resPath = path + "/" + filename;
        return loadProperties(clasz.getClassLoader(), resPath);

    }
666820
public static Properties loadProperties(final String path) {

        if (path != null) {
            // try as file
            try {
                File file = new File(path);
                if (file.exists()) {
                    try {
                        Properties p = new Properties();
                        p.load(new FileInputStream(file));
                        return p;
                    } catch (Exception e) {
                        log.error("Error loading properties from file: " + path);
                    }
                }
            } catch (Throwable e) {
                log.debug(e.getMessage(), e);
            }

            // try as resource
            InputStream inputStream = null;
            try {
                inputStream = PropertyUtil.class.getResourceAsStream(path);
                if (inputStream != null) {
                    try {
                        Properties p = new Properties();
                        p.load(inputStream);
                        return p;
                    } catch (Exception e) {
                        log.error("Error loading properties from resource: " + path);
                    }
                }
            } catch (Exception e) {
                log.error("Error loading properties from resource: " + path);
            } finally {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (Throwable t) {
                        log.debug("Error closing: " + path, t);
                    }
                }
            }
        }


        // return empty Properties by default
        return new Properties();
    }
790350
public static Properties getProps(String fileName) throws Exception
    {
        Properties properties = new Properties();
        InputStream inputStream = PropertyReader.class.getClassLoader().getResourceAsStream(fileName);

        if (inputStream != null)
        {
            try
            {
                properties.load(inputStream);
            }
            catch (IOException e)
            {
                LOGGER.error("JSON is null or empty.");
                throw new KunderaException("JSON is null or empty.");
            }
        }
        else
        {
            throw new KunderaException("Property file: [" + fileName + "] not found in the classpath");
        }
        return properties;
    }
199303
public static Properties getProperties(String classpath) {
        Properties properties = new Properties();
        try (InputStream is = getResourceInputStream(classpath)) {
            properties.load(is);
            return properties;
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "getProperties", classpath);
        }
    }
273753
public static Properties loadClasspath(String path) throws IOException {
		InputStream input = PropUtils.class.getClassLoader().getResourceAsStream(path);
		Properties prop = null;
		try {
			prop = load(input);
		} finally {
			IOUtils.close(input);
		}
		return prop;
	}
116145
public static List<String> readListResource(Class<?> clazz, String path)
    {
        File targetFile = resolve(clazz, path);
        if (targetFile == null)
        {
            return null;
        }

        List<String> result;
        try
        {
            result = FileUtils.readLines(targetFile, "UTF-8");
        }
        catch (IOException ex)
        {
            return null;
        }

        return result;
    }
168747
public static File getClassFile(Class<?> clazz) {
    File dir = new File(clazz.getProtectionDomain().getCodeSource().getLocation().getPath());
    if (!dir.isDirectory()) return null; // class file might be contained in Jar
    File clazzFile = new File(dir, clazz.getName().replace('.', File.separatorChar) + ".class");
    return clazzFile.isFile() ? clazzFile : null;
  }
882085
public static Properties readPropertiesFile(String fileName) {
		InputStream in = getInputStream(fileName);
		if (in != null) {
			return readPropertiesStream(in);
		}
		return new Properties();
	}
986900
public static boolean isPropertyGettable(
                    final Class<?> clazz,
                    final String propertyName
                    )
    {
        if (clazz == null) {
            throw new IllegalArgumentException( "no class specified" );
        }

        if (propertyName == null) {
            throw new IllegalArgumentException( "no property specified" );
        }

        PropertyAccessor  accessor = _findAccessor( clazz, propertyName );

        return (accessor == null ? false : accessor.isGettable());
    }
413946
public static String getPackagePath(Class<?> clazz) {
		return getPackage(clazz).replace(StrUtil.C_DOT, StrUtil.C_SLASH);
	}
353963
public static String getPackagePath(final Class<?> clasz) {
        checkNotNull("clasz", clasz);
        return clasz.getPackage().getName().replace('.', '/');
    }
953344
public static Map<String, BeanProperty> getAllProperties(Class clazz) {
        synchronized (cPropertiesCache) {
            Map<String, BeanProperty> properties;
            SoftReference<Map<String, BeanProperty>> ref = cPropertiesCache.get(clazz);
            if (ref != null) {
                properties = ref.get();
                if (properties != null) {
                    return properties;
                }
            }
            properties = createProperties(clazz);
            cPropertiesCache.put(clazz, new SoftReference<Map<String, BeanProperty>>(properties));
            return properties;
        }
    }
1065936
private static LineMap loadScriptMap(Class cl)
  {
    ClassLoader loader = cl.getClassLoader();

    if (loader == null)
      return new LineMap(); // null map
    
    try {
      String pathName = cl.getName().replace('.', '/') + ".class";

      InputStream is = loader.getResourceAsStream(pathName);

      if (is == null)
        return null;
      
      try {
        JavaClass jClass = new ByteCodeParser().parse(is);

        Attribute attr = jClass.getAttribute("SourceDebugExtension");

        if (attr == null) {
          int p = cl.getName().indexOf('$');

          if (p > 0) {
            String className = cl.getName().substring(0, p);

            return loadScriptMap(loader.loadClass(className));
          }

          return new LineMap();
        }
        else if (attr instanceof OpaqueAttribute) {
          byte []value = ((OpaqueAttribute) attr).getValue();

          ByteArrayInputStream bis = new ByteArrayInputStream(value);

          ReadStreamOld rs = VfsOld.openRead(bis);
          rs.setEncoding("UTF-8");

          try {
            return parseSmap(rs);
          } finally {
            rs.close();
          }
        }
        else
          throw new IllegalStateException(L.l("Expected opaque attribute at '{0}'",
                                              attr));
      } finally {
        if (is != null)
          is.close();
      }
    } catch (Throwable e) {
      log.finer(e.toString());
      log.log(Level.FINEST, e.toString(), e);

      return new LineMap(); // null map
    }
  }
1269911
public static Properties load(File file) throws IOException {
		FileInputStream input = new FileInputStream(file);
		Properties properties = null;
		try {
			properties = load(input);
		} finally {
			IOUtils.close(input);
		}
		return properties;
	}
624496
private static String getPackageName(Class<?> clazz) {

        LettuceAssert.notNull(clazz, "Class must not be null");
        return getPackageName(clazz.getName());
    }
964386
public static Properties loadProperties(final URL fileURL) {
        checkNotNull("fileURL", fileURL);
        final Properties props = new Properties();
        try (final InputStream inStream = fileURL.openStream()) {
            props.load(inStream);
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
        return props;
    }
275966
public static String getClassFileName(Class<?> clazz) {
		Assert.notNull(clazz, "Class must not be null");
		String className = clazz.getName();
		int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
		return className.substring(lastDotIndex + 1) + CLASS_FILE_SUFFIX;
	}