2个回答
展开全部
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();
}
}
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();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询