The Artima Developer Community
Sponsored Link

Java Answers Forum
java code for a search engine

2 replies on 1 page. Most recent reply: Oct 23, 2003 1:05 PM by Matt g

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
mayur

Posts: 1
Nickname: mayu
Registered: Oct, 2003

java code for a search engine Posted: Oct 22, 2003 10:16 AM
Reply to this message Reply
Advertisement
Hi,
i am doing a project on search engine
can anyone provide me with a code for the same which will be of great help
its urgent


Lars Marius Garshol

Posts: 6
Nickname: larsga
Registered: Oct, 2003

Re: java code for a search engine Posted: Oct 23, 2003 5:01 AM
Reply to this message Reply
What kind of search engine? There are lots of different types.

If you are looking for a full-text search engine then search for the Lucene on Jakarta. It's a great piece of work.

Matt g

Posts: 1
Nickname: mattg1981
Registered: Oct, 2003

Re: java code for a search engine Posted: Oct 23, 2003 1:05 PM
Reply to this message Reply
Here is the code for a binary search ...

This is from code I was using earlier in the year to search for a students last name. value = to the name you want to find, student[] was an array full of students, and had a 'getter' called lastName.

It will return the index of the what you were searching for, or a -1 if the string could not be found.


public int binarySearch(String value)
{
int a = 0, mid;
int z = numStudents;

while (a <= z)
{
mid = (a+z)/2;

if (value.compareToIgnoreCase(student[mid].lastName()) == 0)
return mid;
else if (value.compareToIgnoreCase(student[mid].lastName()) >= 1)
a = mid + 1;
else
z = mid - 1;
}
return -1;
}

Flat View: This topic has 2 replies on 1 page
Topic: Searching / Reading a txt file...!! Previous Topic   Next Topic Topic: search engine for a pdf file

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use