I'm given a project to develop program to search text files in a folder to find matches for a given text and list the containing files. I can't use Java built-in data structures. I have to use my own data structures with algorithms.
I thought of building a data-structure similar to a hash-map to contain the strings found in text files. But i cant think of an algorithm to search.

Thanks in advance for any help!.

Recommended Answers

All 11 Replies

All you would need to do is loop thru all the files in the dir, then, in that loop, read thru each file until either you match the text or reach EOF.
What data structures would you need?

First I need to index the strings found in files to optimize the search.

I got a way have a list of txt fils and folders, when we give the rootpath,here it is.

File listOffiles[];
rootFolder=new File(rootPath);
listOffiles=rootFolder.listFiles();//list to store

Here listOffiles will have the list of txt files & folders.
Then try to implement the rest.

Thank you!
I could finish it :-)

But I want to optimize the algorithm.
I searched abooout some text compression algorithms to create codes for words, will it be effective instead of String.compare method?

is any one there to help me? i need to know how a text folder is searched using java..
.

is any one there to help me? i need to know how a text folder is searched using java..
.

There is no such thing as a text folder.
Also start a new thread with some code since in this thread there were some suggestions.
If those do not cover you, make your question a little bit more clear

Hi
im doing my final year in engineering in that we have to undergo a project. i am doing text search that is if we give a name like sachin and if that word present in that folder it has to display its content. how to do this?

Hi
im doing my final year in engineering in that we have to undergo a project. i am doing text search that is if we give a name like sachin and if that word present in that folder it has to display its content. how to do this?

Also start a new thread with some code since in this thread there were some suggestions.
If those do not cover you, make your question a little bit more clear

how to see your coding? i couldn't find...

how to see your coding? i couldn't find...

This thread has a few suggestions. If you still have problems then START a new thread, with specific questions followed with what you have done so far

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.