java解析.properties文件专门有个工具类:Properties
`public class WebServer {
static Properties p = new Properties();
static
{ _//配置web服务的端口
_**try **{<br /> FileInputStream in=**new **FileInputStream(**"./config.properties"**);<br /> _p_.load((in));<br /> String port=_p_.getProperty(**"admin.port"**);<br /> } **catch **(FileNotFoundException e) {<br /> e.printStackTrace();<br /> } **catch **(IOException e) {<br /> e.printStackTrace();<br /> }
}<br /> _//web服务启动<br /> _**public void **start()<br /> {<br /> SimpleServer server= HttpUtil._createServer_(Integer._parseInt_(_p_.getProperty(**"admin.port"**)));<br /> server.start();<br /> System.**_out_**.println(**"服务器启动"**);<br /> Action action=(request,reponse)-><br /> {<br /> reponse.write(**"hello web"**);<br /> };<br /> server.addAction(**"/admin"**,action);<br /> }
**public static void **main(String[] args) {<br /> WebServer webServer = **new **WebServer();<br /> webServer.start();<br /> }
}`