public static void PDF_Read(String object, String data) throws Exception{ try{ Log.info("Radio Button has been selected"); List<String> outputs = new ArrayList<String>(); System.setProperty("webdriver.chrome.driver", Constants.Path_driver); WebDriver driver = new ChromeDriver(); File[] files = new File(object).listFiles(File::isFile); for (File file: files) { String fileExtension = file.getName().split("\\.")[file.getName().split("\\.").length - 1]; if (fileExtension.toLowerCase().equals("pdf")) { String fileUrl = "file:///" + file.getAbsolutePath(); driver.get(fileUrl); URL url = new URL(driver.getCurrentUrl()); InputStream is = url.openStream(); BufferedInputStream fileToParse = new BufferedInputStream(is); PDDocument document = null; String output; try { document = PDDocument.load(fileToParse); output = new PDFTextStripper().getText(document); } finally { if (document != null) { document.close(); } fileToParse.close(); is.close(); } outputs.add(output); //System.out.println(outputs); //Log.info ("The "+file.getName()+" File Containes"+ data+"="+output.contains(data)); //System.out.println ("The "+file.getName()+" File Containes"+ data+"="+output.contains(data)); } } //return outputs; //driver.quit(); return; }catch(Exception e){ Log.error("Radio Button has not been selected --- " + e.getMessage()); DriverScript.bResult = false; } } // second method which i am trying to pass the variables and information's from the first method public static void PDF_VALIDATION( String data,String output, File file){ try{ // Log.info("Closing the browser"); //Log.info ("The "+file.getName()+" File Containes"+ data+"="+output.contains(data)); System.out.println ("The "+file.getName()+" File Containes"+ data+"="+output.contains(data)); return; }catch(Exception e){ Log.error("Not able to Close the Browser --- " + e.getMessage()); DriverScript.bResult = false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)