Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Performing searches in files  RSS feed

 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am facing a problem with performing searches in files (details below):-

The code is written in Java and the aim is to automate a painful process.

Search for a block say in a huge big bunch of files which are inside folders and subfolders:

boolean isRequired()
{
return true;
}

2)Once the above search is done, the search should look for words containing the string �PAGE� (substring search] in the files containing the above block.
[Point 2) search is an AND with point 1)]
These words are constants like JASU_PAGE or ABC_PAGE.

3)After these two searches are done the values of the constants are to be searched in some other files like IConstants.java, it is so since the values are lying in a different file and these constants are being used in the above said files.

The final output should look like :-


File Containing the BlockValues of Constants found in the file
��
1) File1.java1) JASU_PAGE=123
2) --
3) --

So can anyoone guide to do this ??

Saurabh
��
��
 
pradeep jaladi
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1) Performing search for particular files like ".jsp" or "J*" etc...

In Core package java.lang we had a collection of classes like pattern, etc.. with combination of java.io.* packages we can do the thing.

If you can develop code using that packages.

When Performance compared with windows search option
little bit of time extra time is taken by Java Application

2) Once you got the files. suppose you want to search for a word "INDIA" in a particular file .

First check for "I" in the file and is "I" is found then get the "INDIA".getLength(); Starting from the location of "I" and compare with your keyword.

These is the one of the optimization search technique
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pradeep jaladi:
Hi,
1) Performing search for particular files like ".jsp" or "J*" etc...

In Core package java.lang we had a collection of classes like pattern, etc.. with combination of java.io.* packages we can do the thing.

If you can develop code using that packages.

When Performance compared with windows search option
little bit of time extra time is taken by Java Application

2) Once you got the files. suppose you want to search for a word "INDIA" in a particular file .

First check for "I" in the file and is "I" is found then get the "INDIA".getLength(); Starting from the location of "I" and compare with your keyword.

These is the one of the optimization search technique


Can someone be more precise on this as this is in general i also know.?? Please understand the complexity of my problem and let me know the solution if u can.

Thanks anyways
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you use outside code? I use Lucene with great satisfaction. It goes through an indexing phase and builds an index of the files you give it. Searches are lightning fast.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!