package org.kne.cloud.network.klalb; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.PrintStream; import java.net.Inet6Address; import java.net.UnknownHostException; import java.util.Properties; import java.util.UUID; public class ServerPropties extends Properties { /** * */ private static final long serialVersionUID = 1L; public ServerPropties() throws IOException { super(); load(); } public void load() throws IOException { File f=new File("kserver.ini"); if(!f.exists()||f.length()==0) { f.createNewFile(); PrintStream ps=new PrintStream(f); ps.println("virtualip="+ KLALBUtils.uuidToIP(UUID.randomUUID()).getHostAddress()); ps.println("bind=0.0.0.0:4568"); ps.println("local=127.0.0.1:25565"); ps.close(); } FileReader fr = null; try { fr=new FileReader(f); load(fr); }finally { if(fr!=null) fr.close(); } } public Inet6Address getVirtualIP() { try { return (Inet6Address) Inet6Address.getByName((String) get("virtualip")); } catch (UnknownHostException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } return null; } public String getBind() { return (String) get("bind"); } public String getLocal() { return (String) get("local"); } }