Hi guys, i have a text file which has the following data inside.
Account Id = 123
Name = Matt Damon
Address = 465 Ripley Boulevard, Oscar Mansion, Singapore 7666322
DOB = 10-10-1970
Phone Number = 790-3233
Account Balance = 405600.00
Account Id = 126
Name = Ben Affleck
Address = 200 Hunting Street, Singapore 784563
DOB = 25-10-1968
Phone Number = 432-4579
Account Balance = 530045.00
I have tried to use the split method to split the data into tokens and put them into the various category like account id, name, address etc...but it returns null when i execute the program. Please advise me. Thank You
I'm not sure what you mean by "it returns null"...but...
I'd suggest you try using a lot of System.out.println() statements to figure out what your code is doing. If you don't think the split() call is working, put some in after your split() call, and see what is really happening.
Try printing out the length of your temp array. Try writing a quick loop that prints every element in the array. Sure, you'll just delete the code later, but that's ok. When I code, I often end up with HUGE chunks of commented code. As I test and fix, I put in more printlns, then comment them out. I want to keep them for a while, since I know I'll be doing a lot of testing, and don't want to have to re-invent it.
so prove to yourself that the split() call is or is not working. In either case, you can then focus your attention on the correct spot in your code.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Your code is not complete and I'm assuming that you have deliberately removed some. Keeping that aside, where are you seeing null, at what line of hte code. I see tht your for loop is inside your while loop, but in for loop you are using temp being set to all the record attributes, so ideally you are saving the same data....
Try to run this in debug mode and you will find the root cause.