Issue with "Method in Class cannot be applied to given types"

Gman0064

I'm working on a digital time capsule that I'm hosting on my Raspberry Pi as a fun little project. My program is set to work like a regular command prompt, where when you type in a specific command, it downloads a copy of the news website and stores it into an Apache folder (needs to be set up!) to be accessed from the web. Right now I'm working on an autonomous mode, where it creates new archives every 24 hours and makes new files without replacing the old ones. The problem though is that on line 434 it throws this issue.

Method createNewFile in class File cannot be applied to given types;
        file.createNewFile(fileName + (count));

Any help I get is GREATLY appreciated, and here is an excerpt where the problem occurs

class ScheduledLoop extends TimerTask {
URL url;
int count = 0;
public void run() {
    System.out.println("Hello World!");
    try {
        // get URL content
        url = new URL("http://www.wsj.com/");
        URLConnection conn = url.openConnection();

        // open the stream and put it into BufferedReader
        BufferedReader br = new BufferedReader(
            new InputStreamReader(conn.getInputStream()));

        String inputLine;

        //save to this filename
        String fileName = "H:/Retrieval_WSJ.html";
        File file = new File(fileName);

        if (!file.exists()) {
            file.createNewFile();
        }
        else
        {
            count++;
            file.createNewFile(fileName + (count));
        }

        //use FileWriter to write file
        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);

        while ((inputLine = br.readLine()) != null) {
            bw.write(inputLine);
        }

        bw.close();
        br.close();

        System.out.println("SCHEDULE_LOOP: Retrieval Of Wall Street Journal Finished!");

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
    }   
}
Clément

createNewFile takes 0 arguments, not 1.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related