using a file name as argument

I am newbie and I could not figure out what the mistake I am making. I want to test if 2 files exists, if not they should be created and if they exist I should be able to read their contents. I am testing just for one file.

Can anyone help please?

The code is as follows:

import java.io.*;

import java.util.*;

publicclass Daniel

{

publicstaticint secretNumber;

publicstaticint numberOfTries=0;

publicstaticvoid main (String[]args)

{

// create myObject as instance of Daniel class

Daniel myObject=new Daniel();

/* We will first check if 揻irstFile.txt?and 搒econdFile.txt?exists if not we create them.

The first file will hold the data that represents the tries, and the second file will hold

the saved secret number which is the number generated by the system and the number of

tries which must be less than 10, otherwise the game will be over*/

File score =new File("firstFile.txt");

File extraData =new File("secondFile.txt");

boolean firstExists = (new File("firstFile.txt")).exists();

boolean secondExists = (new File("secondFile.txt")).exists();

if ((firstExists) ||(secondExists))

{

readTheFileOfTries("firstFile.txt");

// readTheFileOfOtherData("secondFile.txt");

}

else

{

//initilize the number of tries

numberOfTries = 10;

char[] arrayOfTries =newchar[9];

/* array that will hold all the tries just in case the player need to save the game,

the array will be written to the file firstFile.txt */

//boolean success = score.createNewFile();

}

// call display the game rule method

//myObject.rulesOfTheGame();

}

//厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖厖

publicvoid readTheFileOfTries(String myFile)

{

String lineExtracted;// declaring lineExtracted as string

BufferedReader fileStreamData =new BufferedReader(new FileReader(myFile));

lineExtracted = fileStreamData.readLine();

/* start reading the file till reaching an empty line to remind player about the score saved */

while ( lineExtracted !=null )

{

// display each line extracted to the user which is normally represents a try.

System.out.println(lineExtracted);

/* Once a line is extracted we increment the number of tries

just to find out how many tries are left*/

numberOfTries = numberOfTries + 1;

lineExtracted = fileStreamData.readLine();

}

// display how many tries are left in the game

System.out.println("You have used");

System.out.println(10-numberOfTries);

System.out.println("tries");

fileStreamData.close();// close the file

}

}

This is the error I get from the compiler:

/tmp/29889/Daniel.java:29: non-static method readTheFileOfTries(java.lang.String) cannot be referenced from a static context

readTheFileOfTries("firstFile.txt");

^

1 error

[5030 byte] By [tonymontannaa] at [2007-10-2 22:14:18]
# 1
main is a static method; readTheFileOfTries isn't. This means you have to call readTheFileOfTries on an object of class Daniel, e.g.:myObject.readTheFileOfTries("firstFile.txt");
Lokoa at 2007-7-14 1:31:13 > top of Java-index,Java Essentials,Java Programming...
# 2
thanx loko.
tonymontannaa at 2007-7-14 1:31:13 > top of Java-index,Java Essentials,Java Programming...