java map赋值_java 中的map怎么没有办法赋值?
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
package cn.jado.framework.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class ReadMap {
public static Map maps = new HashMap();
public static void main(String[] args) {
String fileName = "e://習慣同義詞.txt";
File file = new File(fileName);
BufferedReader reader = null;
try {
System.out.println("以行為單位, 一次讀一整行");
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
while ((tempString = reader.readLine()) != null) {
System.out.println("line " + line + ": " + tempString);
String[] ss = tempString.split(" ");
System.out.println("ss:" + java.util.Arrays.toString(ss));
for(int i = 0; i < ss.length; i ++){
ss[i] = ss[i].replaceAll(" ", "");
}
maps.put(ss[0], ss);
System.out.println("結果:"
+ java.util.Arrays.toString(maps.get("中國")));
line++;
}
reader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
總結
以上是生活随笔為你收集整理的java map赋值_java 中的map怎么没有办法赋值?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql-proxy安装包_Mysql
- 下一篇: java 参数 string_关于Jav