Properties Properties =NewProperties ();//Method 1Try { //Loaded in the loaded class file, the file is placed in the class fileClassLoader loader = Propertiesutil.class. getClassLoader (); InputStream instream= Loader.getresourceasstream ("Config.properties"); Properties.load (instream); Value=Properties.getproperty (Propkey);} Catch(Exception e) {logger.error ("An error occured!");}//Method 2Try { //loadallproperties Direct Use pathProperties =propertiesloaderutils. Loadallproperties ("E:/config.properties"); Properties.getproperty (Propkey);} Catch(Exception e) {logger.error ("An error occured!");}//Method 3Try{Resource Resource=NewClasspathresource ("Config.properties"); Properties=propertiesloaderutils.loadproperties (Resource); Value=Properties.getproperty (Propkey);} Catch(Exception e) {logger.error ("An error occured!");}//Method 4Try{Resource Resource=NewClasspathresource ("Config.properties"); Propertiesloaderutils.fillproperties (properties, Resource); Value=Properties.getproperty (Propkey);} Catch(Exception e) {logger.error ("An error occured!");}
Read the properties file in Java