Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir,i have doing application Banking system in core java .thats records stored in text file so already i assign id no 101 for one record ..if we insert another records in txt file ..that assign automatically 102 in Prefix then what should i do ..please suggest.

What I have tried:

fWrite = new FileWriter("C:\\Users\\hp\\Desktop\\BankReport\\master.txt",true);// file is created if not existing
																					// or overwritten if existing
			bRead = new BufferedReader(new InputStreamReader(System.in));// read the data from console
			pS = new PrintStream(System.out);// use like Sysout

			pS.println("Welcom to SignUp....");
			pS.println("=====================");

			pS.println("Enter Customer Name");
			String custName = bRead.readLine();

			pS.println("Mobile Number");
			String custMobNo = bRead.readLine();

			pS.println("Enter Deposit Amount");
			String custDepoAmt = bRead.readLine();

			pS.println("Your SignUp is Successfully ....");

			// write data into the text file

			fWrite.write(custName);
			fWrite.write("#");

			fWrite.write(custMobNo);
			fWrite.write("#");

			fWrite.write(custDepoAmt);
			fWrite.write("\n");
Posted
Updated 28-Apr-21 9:15am

1 solution

You need a way to store, retrieve and update the last # ... maybe another "text file"; an "ini" file perhaps.

https://en.wikipedia.org/wiki/INI_file

(To the troll: yes, he could use a "database")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900