Search for a word in files

Hi all,
i need a help here..
i am doing document search in my jsp application...i have all my files inside a folder..folder contains many folders and inside many files are there..if i specify one string it should display all the files that contains that word.
for example if i search a word "welcome" if any file that contains welcome at any part of document it should specify that file along with the path and then the file should open when i click the link..pls tell me how to do that..

Have a recursive method that takes as a parameter a File, an ArrayList of matches so far, and the String to search for. In your servlet, call it with a blank arraylist. Then iterate through the arrayList, and instead of outputting the path on the file system, output the URL.
     private void fileSearch(File currdir, ArrayList matches, String word) throws IOException{
          File[] fileset = currdir.listFiles();
          for (int i =0; i <fileset.length; i++){
               if (fileset.isDirectory()) fileSearch(fileset[i], matches, word);
               else{
                    BufferedReader reader = new BufferedReader(new FileReader(fileset[i]));
                    boolean found=false;
                    while (reader.ready() && !found){
                         String currline = reader.readLine();
                         if (currline.indexOf(word)!=-1){
                              matches.add(fileset[i].getAbsolutePath());
                              found=true;
                    reader.close();

Similar Messages

  • How do I search for a word through multiple files in my directories ??

    Hello everyone
    How do I search for a word through multiple files in my directories ??
    I am guessing one tedious way to do it would be to pass all the file names as command line arguments but I"m sure there exist a much easier and faster way to do it.
    Thanks a lot

    You need to pass only the directory name as parameter and then retrieve the files(recursively throug subdirs or not, however you wish) of that directory.
    There were at least 2 threads yesterday on how to retrieve files from directory, and there are many others in the archive so I leave the search part to you ;)
    HTH
    Mike

  • Tell me Logic for search for duplicate words(or strings) in a large file.

    Search for duplicate words (or strings) in a text file containing one word per line. For each word that occurs more than once in the flat file output should be as follows
    <word> <number of occurrences> <line numbers in the file where the word occurs>
    For example, if the word Hello occurs thrice in a file at lines 100, 178 and 3456 the output should read
    Hello, 3, [100, 178, 3456]

    Incidentally i wrote similar code some days back. You need to do some modifications to get the exact output you want, but i hope it will be of some help.
    One more thing its written using JAVA5
    public class Test
         private static final String COLLECTIONS_TEXT = "C:\\Documents and Settings\\amrainder\\Desktop\\Collections.txt";
         public static void main(String[] args) throws IOException
              findDuplicateWords();
         private static void findDuplicateWords() throws IOException
              Collection<String> words = new LinkedHashSet<String>();
              File file = new File(COLLECTIONS_TEXT);
              StreamTokenizer streamTokenizer = new StreamTokenizer(new FileReader(file));
              int token = streamTokenizer.nextToken();
              while(token != StreamTokenizer.TT_EOF)
                   if(token == StreamTokenizer.TT_WORD)
                        words.add(streamTokenizer.sval);
                   token = streamTokenizer.nextToken();
              System.out.println(words);
    }Cheers,
    Amrainder

  • Will not search for a word in pdf file. Using Windows 7

    Like most I have used Acrobat reader for viewing PDF files for years.  I recently upgraded to Windows 7 from XP.  I have tried to search a PDF file for a word and it always comes up with none found even though I search for a word that is displayed in the document I'm looking at.  Any advice?
    Regards,
    Dwight

    If the PDF is not a scanned image, can you share it with us: https://forums.adobe.com/thread/1070933

  • Searching for a word or phrase in a file on NSS Pool/Volume

    I have encountered a strange issue in that if I search for a word or phrase in a file at any level of the volume, from the root, down to sub folders, I get different results from 2 or more PC's.
    Workstations are all Win XP SP2, Novell Client 4.91 SP4 for Windows
    Server NW 6.5 SP6 with all post SP's installed.
    I have ran a nss /PoolRebuild=POOLNAME and a NSS /VisibilityRebuild=VOLNAME
    There is only one volume on this pool.
    And I still encounter the same results.
    As one example:
    On my Admin workstation When I search the top level Folder of Closed Client folders for the word chronology, I get 2 files returned named chronfile1 and chonfile2, when I search from any other workstation (I have tried 4 different workstations at this point) at the same folder level, for the same word Chronology, I get multiple files with the Word in the File, but I do not see files chronfile1 or chronfile2. Likewise, the file names returned form the search results on the other workstations, are not returned in the search list ran on the admin (Mine) workstation. And yes, I am logged in as admin on the other workstations when running the search.
    So far, this issue is only appearing on 1 volume.
    Thoughts?

    Originally Posted by ataubman
    If you log in to the second PC as Admin, does the symptom move? IOW does it follow the user or the workstation? If the user you may have some odd file system rights set, although your specific results you report are puzzling.
    I'm assuming you are using the Windows desktop search tool?
    I ran a NSS /PoolRebuild last night which fixed an issue the workstations not being able to see the 2 files in question.
    Previous night I had just performed an NSS /PoolVerify.
    Part of the other anomoly, the other workstations seeing more files than the admin workstation (I feel so Stupid, after 25 years you think I'd be able to spot the obvious) the reason the other workstations were returning files that the Admin workstation was not - Admin workstation doesn't have Word Perfect installed.
    Somebody, give me a Gibbs head slap, now!

  • Search for "A word or phrase in the file" in .trc files gives no result

    Hi
    When i Search through Explorer using search for "A word or phrase in the file" in .trc files I get no result.
    Probably because these files are of type "Microsoft Network Monitor Document".
    But I can open them using Notepad, so why can't I search for a word in these files?
    I there another way to search?
    Normally I ofcourse use Visual Admin. but there are a lot of trace files so it would be nice to do this kind of search
    br Peter

    Hi Peter,
    This is a known problem, see http://support.microsoft.com/kb/309173
    An alternative is to use other tools which search even faster than the slow MS search does.
    Hope it helps
    Detlev

  • Search for more words one time

    Goodmorning, as long someone could help me with the other issue http://forums.adobe.com/thread/1057325?tstart=0 I have another question for you.
    I need to search for a specific list of words but I want to search only one time... So for example if I'm searching 3 different words HELLO - GOODBYE - CIAO I want that acrobat perform the searches in the same time and let me see how many times the words are repeated.
    I try with the advanced search but I can only search one word at time...  I see there is a command under tools>protection>find and remove text (hope I have translate right from Italian software) to search for different words in the same time but the problem is that it can't report how many times thw words are repeated. As you see I need a mix of the two tools
    Do you have some suggestions?
    Hope to read you soon. Thanks,
    Luca
    PS: I know I can do that with the boolean expression but in this way acrobat doesn't separate the rusults.

    It will work with any of the smart album criteria - file menu ==> new smart album
    The easiest way to see is to take a look at what is available there - and make a smart album or two - if you don't like them just drag them to the iPhoto trash and do another one
    LN

  • Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc. This is a new problem and was not the case before.

    Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc.
    This is a new problem and was not the case before.

    Works perfectly fine for me with the latest Reader version (11.0.09).
    You write that it worked "before"; before what?  An update?  Update from what version to what version?

  • Can't open MOV files in FCP: "Searching for movie data in file..."

    I know this has been posted before, but none of them seem to match up to what I'm all of a sudden dealing with. I have 4 MOV files that I'm converting to WMV. Movie 1 & 2 exported fine. Now, however, any time I try to open another MOV file, I get an error that it's "Searching for movie data in file..." and the file name is ALWAYS the same. The weird thing is, the file it's looking for is none of the 4 movies I'm working with. So how did the first two work and this pop out of nowhere??
    I have cleared out the render cache. Dumped all the cache and prefs files I can find, etc. Restarted the machine. Started FCP with the Option key held down.
    I've searched everywhere, but people usually seem to come across this error while opening FCP (I'm running 6.0.6). This only happens when I open a MOV file (oddly, I can open WMV files in FCP without issue).
    HELP!

    So, I open the movies in QT and the EXACT same thing is happening. So it appears the guy who created the videos did something when he was making them (probably made a reference files along the way). I'm having him re-export the MOV files.
    So, it's not a FCP issue.....

  • How to search for a word in a text editor

    Hi,
       I have created a custom container and added some text to it. Is there any method to search for words in this?

    Lilan,
    To search a character field for a particular pattern, use the SEARCH statement as follows:
    SEARCH <c> FOR <str> <options>.
    The statement searches the field <c> for <str> starting at position <n1>. If successful, the return code value of SY-SUBRC is set to 0 and SY-FDPOS is set to the offset of the string in the field <c>. Otherwise, SY-SUBRC is set to 4.
    The search string <str> can have one of the following forms.
    <str>
    Function
    <pattern>
    Searches for <pattern> (any sequence of characters). Trailing blanks are ignored.
    .<pattern>.
    Searches for <pattern>. Trailing blanks are not ignored.
    *<pattern>
    A word ending with <pattern> is sought.
    <pattern>*
    Searches for a word starting with <pattern>.
    Words are separated by blanks, commas, periods, semicolons, colons, question marks, exclamation marks, parentheses, slashes, plus signs, and equal signs.
    <option> in the SEARCH FOR statement can be any of the following:
    ABBREVIATED
    Searches the field <c> for a word containing the string in <str>. The characters can be separated by other characters. The first letter of the word and the string <str> must be the same.
    STARTING AT <n1>
    Searches the field <c> for <str> starting at position <n1>. The result SY-FDPOS refers to the offset relative to <n1> and not to the start of the field.
    ENDING AT <n2>
    Searches the field <c> for <str> up to position <n2>.
    AND MARK
    If the search string is found, all the characters in the search string (and all the characters in between when using ABBREVIATED) are converted to upper case.
    Pls. Mark

  • BUG: Searching for the word "united" in Contacts returns far too many results

    To recreate this bug:
    1. I open the Contacts App on my iPhone 5 running iOS 6.0.1.
    2. In the search field within the app, I search for the word "united." (For example, if I am trying to located the address book card for United Airlines).
    3. Instead of showing me just the results of companies/people that have the word "united" in their name or notes field, the app returns almost every single one of my contacts as a search result, EVEN THOUGH THESE PEOPLE DO NOT HAVE THE WORD "UNITED" IN THEIR NAME, DESCRIPTION, OR NOTES FIELD.
    I think this might be happening because I have used the iOS feature of connecting my Contact App with Facebook.  Because of this, many of my contacts have the word "unified contact info" in their description. Although this doesn't entirely explain why searching for the word "united" would show "unified contact info" contacts, the Facebook/Contacts App connection may have something to do with this bug.
    Regardless, if I search for the word "united" on my iPhone, the Contact App still returns almost every single contact as a search result, even though the word "united" cannot be found within those contacts.

    I think it is because the system adds "United States of America" to every address by default.
    You need to search using different parameters, for example, "Airlines".

  • Firefox randomly does an automatic search for a word I type and redirects to some website. Any ideas why?

    I've been having this problem for awhile now. If I type a word while using firefox (in a form, searching a page for that word/phrase, etc.), Firefox will later (at a seemingly random time) do an automatic search for that word/phrase and redirect me to some site (e.g. if I search a page for 'history', Firefox will at a random time, redirect me to, for example, history.com). I have no idea what might be causing this, and it is really annoying when I'm filling out a form online and Firefox randomly goes to some site, interrupting what I was doing at the time.

    Do you have that problem when running in the Firefox SafeMode? <br />
    [http://support.mozilla.com/en-US/kb/Safe+Mode] <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    If not, see this: <br />
    [http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes]

  • IMovie error 'searching for movie data in file "IMG_4365.MOV"'?

    my iMovie goes into a loop at startup with the message "searching for movie data in file IMG_4365.MOV"?
    I'm on iMovie 09 (version 8.0.6) and it's driving me mad. Help!

    I am also seeing this bug and often work on 400mb+ presentations that use larger screen sizes and have lots of video assets for work.   On large files I find that autosave is not ideal, and would also like a way to turn it off. The computer that was seeing the issue was running 10.7.5.  It was just updated to 10.8.2 so I am keeping my fingers crossed that it works better now.  Time will tell.
    I also really hope that Apple gives us a real refresh on Keynote on the Mac.  As old as it is, it still ahead of Powerpoint.  But it wont stay that way forever standing still and nobody else has a better alternative that is as fast and flexible to work with.  They are squandering somthing special by letting it gather dust.

  • Searching for movie data in file Name-FIN-00000001

    While starting up FCP (6.0.6) gives an error message "Searching for movie data in file Name-FIN-00000001".
    After 10 to 20 min FCP will start up.
    How do I get rid of this annoying error message when starting up?
    Thanks W.

    As Jim says, this is a render file. However, simply rendering it won't fix this. What is causing this error is a QT reference movie in the project. When you export a QT movie, and make don't make it self contained, it is a reference movie that references media files and render files. When a render file is deleted (FCP does this automatically when the render file is no longer needed) then the refrerence movie can no longer function... one file it references is gone. Simply re-rendering won't fix it, because it is referencing that SPECIFIC render file.
    You need to find and delete the QT Reference movie from your project.
    Shane

  • Searching for movie data in file

    Does anyone know how to fix the problem of the "Searching for movie data in file" interruption and annoyance?  I can not access my movies to edit - or do anything for that matter - because this thing keeps popping up.  Any help would be GREATLY appreciated! 
    Thanks!

    Hi
    Did You move or alter any folder named
    • iMovie Event's - or -
    • iMovie Project's
    Don't - If done try movien all back excatly.
    Moving Event's and Projects must
    • be done within the iMovie Application
    • to a Mac OS Extended (hfs) formatted external/secondary Hard Disk
    (Never to - NetWork Storage or UNIX/DOS/FAT32/Mac OS Exchange formatted devices)
    Free Space on Start-Up (Mac OS) Hard Disk. How Much ?
    Yours Bengt W

Maybe you are looking for

  • Report issue in Production

    Hi Experts, I got an issue in production that it should trigger mails daily once. But this program is triggering for every hour,where to look it pls how to debug this issue?can this FM can check? call function 'DURATION_DETERMINE'     importing      

  • Image/background is perfect in FF not in IE

    not sure what the heck is going on here : but if you look at this site in FF its fine and in IE - there is a gap ( above- "watch these REMAX vids") http://www.joinrec.com/ thanks R

  • Basing a Datablock on Program Unit

    Hi Beginner and confused I have a procedure with (IN OUT) ref cursor returning a RECORD. There is a button on the same form which when pressed generates the where clause of the sql statement in the procedure. I need to display this query in a datablo

  • Please Help, Several Applications Won't Open!

    I'm not sure if this is the right thread for this. Please point me in the right direction if it isn't. I just did a software update. The current "internet security update" was, I believe, one of installs (I wish I paid more attention). Now, I have se

  • Random access file in a midlet

    Hi, I'm trying to develop a small dictionary for MIDP2.0/CLDC1.0, so I need to random access a data file in an efficient way. MIDP API itself only provides a sequential access input stream. What is the best way for me to implement a file input stream