import java.io.*; import java.lang.*; import java.util.regex.*; class updtxta { public static void main(String args[]) throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String bufid,bufname,bufsalary,b,lastid; String fields[] = new String[5]; int lastid_temp; String ar[] = new String[10]; FileReader fin = new FileReader("updtxt.dat"); BufferedReader bin = new BufferedReader (fin); int i = 0; while ((b = bin.readLine()) != null) { ar[i] = b; fields = b.split(","); i = i + 1; } fin.close(); lastid_temp = Integer.parseInt(fields[0]) + 1; lastid = Integer.toString(lastid_temp); // System.out.println("Wait id : " + lastid); bufid = lastid; System.out.print("Wait name : "); bufname = stdin.readLine(); System.out.print("Wait salary : "); bufsalary = stdin.readLine(); // int tot = i; FileOutputStream fout = new FileOutputStream("updtxt.dat"); BufferedOutputStream bout = new BufferedOutputStream(fout); PrintStream pout = new PrintStream(bout); i = 0; while (i < tot) { pout.println(ar[i]); i = i + 1; } pout.println(bufid + "," + bufname + "," + bufsalary); System.out.println("Add : completely"); pout.close(); } }