aspose file tools*
The moose likes Beginning Java and the fly likes [solved]what the syntax for Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "[solved]what the syntax for "if file not exists"?" Watch "[solved]what the syntax for "if file not exists"?" New topic
Author

[solved]what the syntax for "if file not exists"?

L Willie
Ranch Hand

Joined: Aug 10, 2008
Posts: 51

don't know what the correct syntax for "if file not exists".

Sincerely

Willie

[ October 14, 2008: Message edited by: L Willie ]
[ October 15, 2008: Message edited by: L Willie ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42620
    
  65
You can't put an operator in the middle of a method call. It's "if (! file.exists())".


Ping & DNS - my free Android networking tools app
L Willie
Ranch Hand

Joined: Aug 10, 2008
Posts: 51
thank
Anton Pechsherov
Greenhorn

Joined: Sep 09, 2008
Posts: 27
One more simple:


I make different errors when writing posts...because i don't speak English...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39834
    
  28
Never write " == false" or " == true"; it is possible to make a mistake and write " = false" or " = true" instead in which case you have a serious logic error.

It would be much better to writeIf you write if (file.exists() = false), in this case it would probably be a compiler error.
Anton Pechsherov
Greenhorn

Joined: Sep 09, 2008
Posts: 27
Maybe , you can mistakes anywhere.. but it was enother Example ..
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Anton Pechsherov:
Maybe , you can mistakes anywhere.. but it was enother Example ..


Yes, but the point is, it's a bad example, and one which we at the Ranch (as well as experienced programers everywhere) actively discourage people from following. I routinely tell people to never, under any circumstances, compare directly to a boolean literal; the tokens "==" or "!=" should never appear next to "true" or "false" in your code.


[Jess in Action][AskingGoodQuestions]
 
Consider Paul's rocket mass heater.
 
subject: [solved]what the syntax for "if file not exists"?