In the java project development process, using the properties file as the configuration is basically essential, many such as system configuration information, File Upload configuration information, and so on are saved in this way.
Learning to operate the properties file is also the basis of java.
Copy codeThe Code is as follows: public class PropertiesUtil {
Public static Map getFileIO (String fileName ){
Properties prop = new Properties ();
Map propMap = new HashMap ();
InputStream in = PropertiesUtil. class. getResourceAsStream (fileName );
Try {
Prop. load (in );
Setkeyset = prop. keySet ();
For (Object object: keyset ){
String propValue = prop. getProperty (object. toString (). toString ();
PropMap. put (object. toString (), prop. getProperty (object. toString (). toString ());
System. out. println (object. toString () + ":" + propValue );
}
} Catch (IOException e ){
E. printStackTrace ();
} Finally {
Try {
In. close ();
} Catch (IOException e ){
E. printStackTrace ();
}
}
Return null;
}
Public static void main (String [] args ){
GetFileIO ("/loginurl. properties ");
}
}