daima

void readFile()throws Exception
{
File file = new File("D:\\file\\test.csv");
list = new ArrayList<String>();
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));
String line = null;
while ((line = bf.readLine())!=null)
{
list.add(line);
}
bf.close();
}

void writerFile()throws Exception
{
File file = new File("D:\\file\\result.csv");
file.createNewFile();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file),"GBK"));
for (String key : map.keySet())
{
pw.println(key + "," + map.get(key));
}
pw.flush();
pw.close();
}

你可能感兴趣的:(IM)