I am trying to read a text file and set its input into some particular JLabels. Have a look at my code.
Here is the image of the output(Attached)
Here are some data in the text file
Graduation Degree Program: Aeronautics-Astronautics School: St.John College First Name: aaaaaaaaaaaa Middle Name: aaaaaaaaaaaa Last Name: aaaaaaaaaaaa City: aaaaaaaaaaaa State: aaaaaaaaaaaa Zip Code: aaaaaaaaaaaa Country: aaaaaaaaaaaa Country Code: aaaaaaaaaaaa Area Code: aaaaaaaaaaaa Residence Phone Number: aaaaaaaaaaaa Office Countr Code: aaaaaaaaaaaa Office Area Code: aaaaaaaaaaaa Office Phone Number: aaaaaaaaaaaa Email Address: aaaaaaaaaaaa Gender: Male Date Of Birth: aaaaaaaaaaaa/aaaaaaaaaaaa/aaaaaaaaaaaa Citizenship Status: U.S. Permanent Citizen Qualification Details:: Program: Aeronautics-Astronautics Grade: Distinction School: St.John College University: Notinham Univercity Test Date: aaaaaaaaaaaa Score: aaaaaaaaaaaa TOEFL Scoreaaaaaaaaaaaa Details for recent Honar and awards: aaaaaaaaaaaa
(I know it is messy! Just added some testing, not the real data. Anyway, this the details of ONE user)
Now, what I need to do is this. I have to SEARCH the data from the text file. Which means when the user selects SCHOOL and PROGRAM and clicks the OK button, relevant details should be searched according to that, and should replaced with the JLABELS I marked in RED in the image. If there are more than one user, then details of those user should be represented in LINE BY LINE according to the SEARCH. Please help me.. I need immediate assistance. Thank you
I think the first thing you want to do is write an effective parser for your file type. The parsing method could take the name of a file, or to be more general, a Reader (which is better for text than an InputStream). It would then read the file and return an object containing the data in an easy to access form. Looking at your data file, I see a lot of key-value pairs, so I'd guess a big part of the returned data would be a HashMap. Maybe that's all you want to return, or maybe there's also separate fields for program, college, and school. That's up to you. Once you get the parser and return class worked out, I think the rest of your application will be much easier to implement.
(*) No, I wouldn't. There are several things I wouldn't do. Still, I'm impressed.