日期:2014-05-20 浏览次数:20725 次
public static void main(String[] args) throws Exception{ Reader reader = new FileReader("D:\\workspace\\test\\src\\test.txt"); StringBuffer sb = new StringBuffer(); char[] buf = new char[1024]; int i = 0; while((i = reader.read(buf)) != -1){ sb.append(new String(buf, 0, i)); } reader.close(); String str = sb.toString(); str.replace(" ", ""); String[] ss = str.split("\\[node\\d\\]"); Properties p = new Properties(); for(String s : ss){ StringReader sr = new StringReader(s); p.load(sr); System.out.println(p.get("ip")); System.out.println(p.get("port")); System.out.println(p.get("linetype")); System.out.println(p.get("nodecode")); System.out.println(p.get("right")); System.out.println(p.get("nodename")); } }