Fetching the data from .txt file for the request parameter

Discussions

General J2EE: Fetching the data from .txt file for the request parameter

  1. Hi,

    This is my first post in this forum.  I have a .txt file which is as follows:-

     EmpId EmpName EmpAge EmpJoinDate

    100         Anto         25 05-05-2010

    101         Bob          26 05-10-2010

    102         Credic       27 05-15-2010

     ... ... ...

    which contains "n" number of rows with space as a delimeter. From my application i will be passing the "EmpAge", for that age i need to retrieve the row. For eg, if i passing the empage as "25" i need to retrive the values for that row (1st row). Here we are using a txt file and no xml file is used here. If the empage 25 is present in multiple rows, then i need to get those rows as well. Similarly i can pass more than one parameter like empage and empid, etc. How to do it using the IO package. Please do answer my question, if there any links or sample code please do share.

    Also, is it the right approch to use the .txt format or better to store the those .txt file data in a DB and retrieve it from there? Why i am asking this, there is a possibility where we will pass a list of parameters as a collection , hence to fetch the data from those parameters from .txt file is quite tough as lot of comparison check needs to be done, hence with the DB approch it will easy to use as "Select" query and pass the parameters in the "Where" condition. Which is much more faster i believe. Please do share your thoughts.

    Thanks in advance.

    --Rithu

  2. Hi

    Why don't you use the unix based filter commands in your java program .see the below example will give the detail view http://p2p.wrox.com/other-programming-languages/70727-filter-records-file-sed-awk-unix.html.

    Forgive me if you are not using unix environment.

    Thanks, Vijay