package com.helper.doAction;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map.Entry;

import com.helper.Swap.Swap;

/**
 * 小说窗口关闭的时候更新记录文件
 * @author Administrator
 *
 */
public class NovelWindowClose {
	public NovelWindowClose() {
		Swap.historyNovel.put(Swap.novelName, Swap.novelParagraphTemp);//把新的段落记录更新进去
		File novelHistoryFile = new File("novel.his");
		// 存在历史文件
		if (novelHistoryFile.exists()) {
			try {
				WriteConfigFile(novelHistoryFile);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		} else {
			// 不存在则创建
			try {
				novelHistoryFile.createNewFile();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			try {
				WriteConfigFile(novelHistoryFile);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
	}

	/**
	 * 写记录文件
	 * 
	 * @throws IOException
	 */
	public void WriteConfigFile(File file) throws IOException {
		StringBuilder builder = new StringBuilder("");
		for (Entry<String, Integer> entry : Swap.historyNovel.entrySet()) {
			System.out.println(entry.getKey() + "--->" + entry.getValue());
			builder.append(entry.getKey() + "――" + entry.getValue() + "\n");
		}
		BufferedWriter output = new BufferedWriter(new FileWriter(file));
		output.write(builder.toString());
		output.close();
	}
}
最近下载更多
Demo1111  LV30 6月30日
xp95323  LV15 2023年11月27日
微信网友_5852742079762432  LV6 2022年3月2日
wanglinddad  LV55 2022年2月11日
baoxing567  LV9 2021年3月30日
dengdai2018  LV6 2021年2月28日
675104182  LV14 2020年9月22日
yuqm  LV17 2020年8月3日
tinbe  LV11 2018年12月19日
jasyr1314  LV11 2018年10月20日
最近浏览更多
pengkui  LV14 2024年11月29日
微笑刺客  LV21 2024年11月22日
杨秀益  LV1 2024年6月17日
Dominick  LV14 2024年3月5日
xp95323  LV15 2023年11月27日
xingxing1234  LV10 2023年3月22日
Hsy605  LV9 2022年6月20日
1265260263  LV4 2022年4月8日
微信网友_5852742079762432  LV6 2022年2月28日
wanglinddad  LV55 2022年2月9日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友