public static void extract(File file, String outDir)
	{
		String result="";
		String outFileName = null;
		POITextExtractor extractor = null;
		boolean filefound=false;
		
		try {

		
		FileInputStream fis = new FileInputStream(file.getAbsolutePath());
		

		if (file.getName().toLowerCase().endsWith(".docx")) 
		{
		    XWPFDocument doc = new XWPFDocument(fis);
		    extractor = new XWPFWordExtractor(doc);
		    filefound=true;
		    
		} 
		 
		if (file.getName().toLowerCase().endsWith(".doc")) 
		{
			HWPFDocument doc = new HWPFDocument(fis);
		    extractor=new WordExtractor(doc);
		    filefound=true;
		}
		
		if(filefound)
		{
			System.out.println("Processing :"+file.getAbsolutePath());
		    outFileName = file.getName() + ".txt";
			
			result = extractor.getText();
			File outFile = new File(outDir+"/"+outFileName);
			Writer output = new BufferedWriter(new FileWriter(outFile));
	
			
				output.write(result);
				output.close();
		}
		else
		{
			System.out.println("Skipping  :"+file.getAbsolutePath()+" Not A Word Document");
		}
		
		} catch (Exception exep)
		{
			exep.printStackTrace();
			System.out.println("Exception  :");
		}
		
	}