Brajesh Kumar Hayaran

Greenhorn
+ Follow
since Sep 24, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Brajesh Kumar Hayaran

Hi Every Body


i m using httpclient API to upload zip fle on server it is working fine on client side but i need to store this file in a folder on server

i am not able to get on server .

following is the code .


client side :--

serevr side code :---
---------------------
Hi Every Body

i am working on pdf indexing and searching page by page
for redaing pdf page by page i m using "com.asprise.util.*;"
open source.

follwoing is code i have written



public static void main(String[] args) {
// TODO Auto-generated method stub
Document doc = new Document();
String page1 =null;
File f = new File("C:\\testpdf\\springmvc.pdf");
File indexDir = new File("c:\\indexes");
String text=null;



try
{
IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(),
true);
writer.setUseCompoundFile(false);




PDFReader reader = new PDFReader(f);
reader.open(); // open the file.

int pages = reader.getNumberOfPages();
System.out.println("Pages " +pages);
for(int i=1; i <= pages; i++) {
System.out.println("I--> " +i);
if(i==14)
break;
text = reader.extractTextFromPage(i);


System.out.println("Page " + i + ": " + text);
page1= String.valueOf(i);

// System.out.println("page--"+page1);
doc.add( new Field("contents", text,Field.Store.YES,Field.Index.UN_TOKENIZED));
doc.add( new Field("Id", page1,Field.Store.YES,Field.Index.UN_TOKENIZED));
doc.add( new Field("File Name ", f.getCanonicalPath(),Field.Store.NO,Field.Index.TOKENIZED));

doc.add( new Field("page", page1,Field.Store.YES,Field.Index.NO));
text="";

}
writer.addDocument(doc);

writer.optimize();
writer.close();
// perform other operations on pages.

reader.close(); // finally, close the file.
PdTest.search();
}catch(Exception ex)
{ex.printStackTrace();}






}

public static void search() throws Exception {
String q= "spring";

File indexDir = new File("c:\\indexes");
//File dataDir = new File("C:\\testpdf");
Directory fsDir = FSDirectory.getDirectory(indexDir, false);
IndexSearcher is = new IndexSearcher(fsDir);
QueryParser QP = new QueryParser("contents", new StandardAnalyzer());
//Query query = QueryParser.parse(q, "contents", new StandardAnalyzer());
Query query = QP.parse(q);
long start = new Date().getTime();
Hits hits = is.search(query);
long end = new Date().getTime();
System.err.println("Found " + hits.length() + " document(s) (in "
+ (end - start) + " milliseconds) that matched query '" +q
+ "':");
for (int i = 0; i < hits.length(); i++) {
Document doc = hits.doc(i);
System.out.println(doc.get("File Name"));
System.out.println(doc.get("page"));

}
}

but after run the code i m getting
Found 0 document(s) (in 0 milliseconds) that matched query 'spring':

i m giving the a pdf that already contain the "spring" text .

can any body please help me


Brajesh