Read the contents of the configuration file
Read the content information in the configuration file in the project, for example, read the IP address in ipconfig.properties.
/** * Read configuration file information * * @param name read node name * @param fileName filename * @return node value read */ public static String readConfigString(String name, String fileName) { String result = ""; try { ResourceBundle rb = ResourceBundle.getBundle(fileName); result = rb.getString(name); } catch (Exception e) { // log.error("Read from" + fileName + "" + name + "Error:" + e.getMessage()); Log.i(fileName, name); } return result; } Be public static int readConfigInteger(String name, String fileName) { int result = 0; try { ResourceBundle rb = ResourceBundle.getBundle(fileName); result = Integer.parseInt(rb.getString(name)); } catch (Exception e) { Log.i(fileName, name); } return result; } Be public static long readConfigLong(String name, String fileName){ long result = 0; try { ResourceBundle rb = ResourceBundle.getBundle(fileName); result = Long.parseLong(rb.getString(name)); } catch (Exception e) { Log.i(fileName, name); } return result; } Be public static double readConfigDouble(String name, String fileName){ double result = 0; try { ResourceBundle rb = ResourceBundle.getBundle(fileName); result = Double.parseDouble(rb.getString(name)); } catch (Exception e) { Log.i(fileName, name); } return result; }
Content in config file:
health_ip=192.168.1.123:8080/health # commented address #health_ip=yumingdizhi/health
Read the address inside:
String ipAddress = Configuration.readConfigString("health_ip", "ipconfig");
lipitor 80mg pills & lt;a href="https://lipiws.top/"& gt;lipitor 40mg generic& lt;/a& gt; cheap atorvastatin 10mg
Mlhlis
2024-03-07