Jump to content

Scanner help...

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
Hey C.C,

I have been wondering, if I read in a file with scanner and if the file doesn't exist in that path could I do a exception, if it doesn't find path it creates the file... and then proceed with the normal operation?
PS - it is a txt file.

Thanks in advance !

EDIT NOTES - I solved the problem :P, well you guys could give out still a tip for the newcomers that might drop by here

Edited by Turk4n, 10 December 2008 - 12:11 AM.
I solved my problem...

Posted Image

#2
Stu_328

Stu_328

    Learning Programmer

  • Members
  • PipPipPip
  • 92 posts
what do you mean scanner?


File f = new File("your path");

if(f.exists(){

//open the file

}else{

//create a new file

}



#3
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

Stu_328 said:

what do you mean scanner?


File f = new File("your path");

if(f.exists(){

//open the file

}else{

//create a new file

}


Wasn't looking for this. I will show you what I meant later :)
Posted Image

#4
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
How did you solve your problem?

#5
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

chili5 said:

How did you solve your problem?

Just like this...

Scanner variable= new Scanner(new FileReader(argument));

Was looking for this... and I found it while testing out for a longer while...
Posted Image