Results 1 to 7 of 7
  1. #1
    nitin kishore is offline Member
    Join Date
    Sep 2011
    Location
    chennai
    Posts
    3
    Rep Power
    0

    Default Searching for a string in different log files

    it should poll a specific location for the presence of a file in a predefined location (configurable),
    once a file is present it should take the filename as " text string to find ", the location to find is predefined (configurable)

    output :
    find all exact matches of the "text string to find" in all the files in the location
    and generate new files with the output based on the following rules

    a new file for every file that contains the "text string"
    the file name should be same suffixed with the"text string"
    All the newly generated file should be zipped with the filename "text string".zip (or) .jar

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,602
    Rep Power
    23

    Default Re: Searching for a string in different log files

    Do you have any java programming questions or problems?

  3. #3
    nitin kishore is offline Member
    Join Date
    Sep 2011
    Location
    chennai
    Posts
    3
    Rep Power
    0

    Default Re: Searching for a string in different log files

    Dear sir,
    I am beginner in java . I have 100mb log files... On those files i have to search a particular string.. with minimum time..so do some needful for this approach..and pls tell me what kind of approach i have to take..

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,602
    Rep Power
    23

    Default Re: Searching for a string in different log files

    If you are a beginner I suggest you start with a simple program that will read a file line by line, search the line for some text and print the line if it contains the text.

  5. #5
    nitin kishore is offline Member
    Join Date
    Sep 2011
    Location
    chennai
    Posts
    3
    Rep Power
    0

    Default Re: Searching for a string in different log files

    thanks sir for guiding me ... but my main aim is not to program but program in a way that i can use minimum time to find line by 100 mbs log files.. i already know the approach you told me.but it is very time taking and my aim is to find minimum search time

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,602
    Rep Power
    23

    Default Re: Searching for a string in different log files

    Look at the nio package. It might have faster I/O methods.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,602
    Rep Power
    23

    Default Re: Searching for a string in different log files

    I just ran a test reading a 60MB file as bytes using nio and FileInputStream. The time in ms was 94-110 for nio and 109-120 for FIS.
    I think there will be extra time taken converting the bytes to String and searching the String. I suspect that a search in a loop byte by byte will be faster.

Similar Threads

  1. Searching Text Files Then Removing (My First Post!)
    By technoreject in forum New To Java
    Replies: 12
    Last Post: 06-29-2011, 06:51 AM
  2. Searching through folder to find text inside all files
    By dazzabiggs in forum New To Java
    Replies: 3
    Last Post: 05-03-2011, 01:20 PM
  3. Replies: 0
    Last Post: 05-01-2011, 07:23 PM
  4. Searching directories for folders and .txt files
    By XDrew574X in forum New To Java
    Replies: 1
    Last Post: 03-29-2011, 09:41 PM
  5. java searching from many files
    By manish250 in forum Advanced Java
    Replies: 0
    Last Post: 12-31-2010, 07:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •