1. 寫個config.txt 內容如下:
ip = xxx.xxx.xxx.xxx
port = ####
2. 寫如下代碼獲取ip和port
Properties prop = new Properties();
InputStream in = new FileInputStream("config.txt");// full path
prop.load(in);
in.close(); // catach exception
String ip = (String)prop.get("ip");
String portValue = (String)prop.get("port");
自己整理下.. Properties 在 java.util 包裏面..