Java line giving me grief - please help! :)

Hey Guys,

Does anything seem wrong with this line?

((new File(new String(""), "TimeMan.dat").exists());

that is the line that is givving me grief. I think that if that was removed and a "true" put in its place that it would load but i haven't tested that theory. But it means that it would always try and load from file even if it doesn't exist (BAD IDEA).

I know it's not great not having the rest of the code, can you let me know? Thanks heaps.

Really Appreciated

Comments

  • : Hey Guys,
    :
    : Does anything seem wrong with this line?
    :
    : ((new File(new String(""), "TimeMan.dat").exists());
    : ...

    Hi,

    I think the line above should be similar to the following
    [code]
    (new File("TimeMan.dat").exists());
    [/code]

    I don't really get your problem, perhaps you could explain a little bit more in detail? Do you want to test whether a file exists, and if so load it? The following two examples should do so
    [code]
    ...
    if (new File("TimeMan.dat").exists()) {
    //read from file
    }
    ...
    [/code]
    or
    [code]
    ...
    try {
    FileInputStream fstream= new FileInputStream("TimeMan.dat");
    //read from file
    ...
    } catch (FileNotFoundException fnfe) {
    fnfe.printStackTrace();
    }
    ...
    [/code]

    I hope it helps
    greetings moo

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion