导入用户类的存储工具代码
2016-05-07 21:15
344 查看
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; public class IOTools { private static Properties po = new Properties(); static { try { FileInputStream fl = new FileInputStream("userinformation.properties"); po.load(fl); fl.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void OutPutMoney(User user) { po.setProperty(user.getAccount(), user.store()); try { FileOutputStream file = new FileOutputStream("userinformation.properties"); po.store(file, null); file.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } public static void forwardMoney(User user, User user1) { po.setProperty(user.getAccount(), user.store()); po.setProperty(user1.getAccount(), user1.store()); try { FileOutputStream file = new FileOutputStream("userinformation.properties"); po.store(file, null); file.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } public static void changePWD(User user) { po.setProperty(user.getAccount(), user.store()); try { FileOutputStream file = new FileOutputStream("userinformation.properties"); po.store(file, null); file.close(); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block System.out.println("没有找到文件"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
相关文章推荐
- Qt应用程序以管理员身份启动
- python中的赋值
- Java开发中的23种设计模式详解
- MyEclipse配置Maven
- c++第五次上机实验
- 实战 ASP.NET Web API
- Java设计模式
- 关于java.split问题
- 多线程编程
- java多线程
- 空心三角形(图形的输出)c语言
- 代码训练营——TreeSet
- HDU 4417-Super Mario(划分树-二分查找)
- Java线程详解
- 介绍const
- Spring记录之Spring的基本概念
- 第十四章 springboot + profile(不同环境读取不同配置)
- CodeForces-657A-Bear and Forgotten Tree 3
- eclipse最常用的10种快捷键组合
- python 文件读写项目实践