import java.io.*;
import java.util.*;
class Person1{
String id;
String passwd;
Person1(String id, String passwd){
this.id = id;
this.passwd = passwd;
}
}
public class MyFileReaderWriter {
public static void main(String[] args){
Vector personList = new Vector();
String inputFile = "src/password.txt";
String outputFile = "src/password.txt";
try{
FileReader fr = new FileReader(inputFile);
BufferedReader br = new BufferedReader(fr);
String data;
while((data=br.readLine()) != null){
String[] personData = data.split(":");
personList.add(new Person1(personData[0],personData[1]));
}
fr.close();
FileWriter fw = new FileWriter(outputFile);
PrintWriter pw = new PrintWriter(fw);
personList.add(new Person1("dongyang","11112"));
for(int i=0; i < personList.size(); i++){
Person1 p = personList.get(i);
String str = p.id+":"+p.passwd;
pw.println(str);
System.out.println(p.id + p.passwd);
}
fw.flush();
fw.close();
}catch(FileNotFoundException fnfe){ System.err.println("파일이 없습니다.");
}catch(IOException ioe){System.err.println("IO예외가 발생했습니다.");
}
}
}