data extraction, and analysis of text files

Discussion in 'Java' started by mambenanje@gmail.com, Jun 26, 2006.

  1. Guest

    plz I have a project to read text files and extract data and perform
    analysis, so I dont know if ther is any java library readily available
    or any techniques or advice or website plz help me
     
    , Jun 26, 2006
    #1
    1. Advertising

  2. Bart Cremers Guest

    schreef:

    > plz I have a project to read text files and extract data and perform
    > analysis, so I dont know if ther is any java library readily available
    > or any techniques or advice or website plz help me


    It depends a bit on the format of the text file, but a general approach
    would be to read the file using a BufferedReader wrapped around a
    FileReader:

    BufferedReader reader = new BufferedReader(new
    FileReader("inputfile.txt"));

    The BufferedReader allows reading the file one line at a time. If no
    more lines are available, the readLine() method simply returns 'null':

    for (String line = reader.readLine(); line != null; line =
    reader.readLine()) {
    // Process line
    }

    To process the line you'll need to use the various available classes
    for String manipulation available in Java:

    String.split(), String.substring() or StringTokenizer to split the
    line in processable parts.
    The parse methods in the Number classes to convert number to a
    primitive (Integer.parseInt(), ...)
    ...

    Regards,

    Bart
     
    Bart Cremers, Jun 26, 2006
    #2
    1. Advertising

  3. Guest

    well I think I understand your approach yeah when I read the file I
    will use java.util.regex to go through it thanks very much
     
    , Jul 3, 2006
    #3
  4. Guest

    well I think I understand your approach yeah when I read the file I
    will use java.util.regex to go through it thanks very much
     
    , Jul 3, 2006
    #4
  5. I am parsing data from a GPS device.
    The data comes separated by commas, it follows the NMEA protocol.
    What I want to know is how to parse those strings using *as less memory
    as possible*, since I am on the mobile environment, using Java ME (not
    Java 5.0 then).

    Thanks in advance!
     
    Carlos Eduardo Lima Borges, Jul 3, 2006
    #5
  6. Guest

    well I think using the String.split approach will do the job for u and
    it create only one array and returns you a reference and such no memory
    waste
     
    , Jul 6, 2006
    #6
  7. Thanks a lot!

    Do you know anyway so that I can check the number of elements created?
    It can be either directly, knowing the number of created objects in
    memory or indirectly analyzing the size of each element and comparing
    to the amount of free memory changed.
    I donĀ“t know how either of those approaches can be done nor do I know
    any other approaches.
    Any help appreciatted

    wrote:
    > well I think using the String.split approach will do the job for u and
    > it create only one array and returns you a reference and such no memory
    > waste
     
    Carlos Eduardo Lima Borges, Jul 7, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sengly
    Replies:
    13
    Views:
    2,211
    Hermann Peifer
    Nov 24, 2008
  2. ssubbarayan
    Replies:
    5
    Views:
    2,336
    Dave Hansen
    Nov 3, 2009
  3. Vitali
    Replies:
    1
    Views:
    104
    BruceL
    Jul 28, 2010
  4. Replies:
    2
    Views:
    134
    Matt Garrish
    Aug 16, 2005
Loading...

Share This Page