public void savaFile(){//保存用户名
File f=new File(".\\data\\dk.txt");
try {
FileWriter txt=new FileWriter(f);
txt.write(yh.getText()+"-");
txt.write(mm.getText()+"+");
txt.close();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
//读取保存的用户名和密码
public void Duqu() {
FileReader fr;
try {
fr = new FileReader(".\\data\\dk.txt");
BufferedReader br = new BufferedReader(fr);
try {
String line = br.readLine();
yh.setText(line.toString().substring(0,line.toString().indexOf('-')));
mm.setText(line.toString().substring(line.toString().indexOf('-')+1,line.toString().indexOf('+')));
//System.out.print(line);
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
}
取消
评论