Java JFrame 应用笔记

1、exej4编译,Icon窗口图标不显示

修改前

Toolkit toolKit = getToolkit();
Image icon = getToolkit().getImage("./src/img/logo.png");
this.setIconImage(icon);

修改后

URL url = getClass().getResource("/img/logo.png");
Image img = Toolkit.getDefaultToolkit().getImage(url);
this.setIconImage(img);

2、ini配置文件乱码((汉字字符流读取和写入并指定编码格式)直接编辑ini与代码赋值)

//读文件
InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK");
BufferedReader bufferedReader = new BufferedReader(isr);
//写入文件
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "GBK"));

 

你可能感兴趣的:(java)