Click here to Skip to main content
15,884,050 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
while trying to pass variable and information from one method to another method i am getting wrong number of argument exception

What I have tried:

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;
                }
       }
Posted
Updated 1-Feb-21 22:21pm

1 solution

"PDF_VALIDATION"
Your code doesn't call that method at all: so whatever is giving you an "argument count" error isn't that.

Look closely at the error message, it will show you which file and line the problem is on.
Go to that line, and compare the way you are calling the method with the method definition(s) - the number and type of the arguments much match, so if you only method with that name in the appropriate class is defined as taking an integer and a string, then you must call it with two parameter values: the first an integer, the second a string.

Sorry - but we can't do any of that for you!
 
Share this answer
 
v2
Comments
Member 13938502 2-Feb-21 4:46am    
i am actually using a framework in that i am initializing PDF_VALIDATION only then this error is coming
OriginalGriff 2-Feb-21 5:16am    
maybe so - but the code you showed us doesn't call it at all.
Use CTRL+F on this page and search for PDF_VALIDATION.
You will get four references: the definition in the code you show, one in my answer, one in your comment, and one in this comment.
If you don't call it, it's not that code that gives the problem!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900