public static void main(String[] args) throws Exception{
t1();
}
private static void t1() throws Exception{
BufferedInputStream bis = new BufferedInputStream(Test.class.getResourceAsStream("1.txt"));
StringBuilder sb = new StringBuilder();
int len =0;
byte [] b = new byte[bis.available()];
while ((len = bis.read(b)) != -1) {
sb.append(new String(b,0,len));
}
System.out.println(sb.toString());//读取文件内容
Map row = new HashMap();
int i=0;
for(String str :sb.toString().split("\r\n")){
i++;
System.out.println(i+":"+str);
String [] info = str.split(",");
if(row.containsKey(info[1])){
row.put(info[1], row.get(info[1])+","+info[0]);
}else{
row.put(info[1], info[0]);
}
}
System.out.println(row);
}