Meaningless Drivel is fun!*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 39575
    
  27
You can't put an operator in the middle of a method call. It's "if (! file.exists())".


Ping & DNS - updated with new look and Ping home screen widget
L Willie
Ranch Hand

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

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


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

Joined: Oct 13, 2005
Posts: 36575
    
  16
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: 26
Maybe , you can mistakes anywhere.. but it was enother Example ..
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [solved]what the syntax for "if file not exists"?
 
Similar Threads
[answered] Question about GUI design
[solved]:p how to keep "next line" during append String data to StringBuilder
[try2solve]non-varargsCall ofVarargsMethodWith inexact argumentTypeForLastParameter;
[solved]how to add bouncycastle package to java?
[solved]how JTextField listen to JFileChooser