A Nonexistant File

J

Jason Cavett

Is there a specific String I can use to create a file such that
file.exists() will always return false?

Basically, I'm trying to avoid having to check for null all the time.
So, when I create a new project, I want to set it's starting save path
(AKA it hasn't been saved yet) to something where file.exists() =
false. String path = new String("") *seems* to work, but I wanted to
make sure.

Thanks
 
E

External Concepts Guild

Is there a specific String I can use to create a file such that
file.exists() will always return false?

Basically, I'm trying to avoid having to check for null all the time.
So, when I create a new project, I want to set it's starting save path
(AKA it hasn't been saved yet) to something where file.exists() =
false. String path = new String("") *seems* to work, but I wanted to
make sure.

Thanks

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Probably not. If there were, it would be OS specific.

Maybe you could use
File.createTempFile(String prefix,String suffix).

Emory Merryman
External Concepts Guild
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHf5XfVQdj5Q2e9q0RAj4uAJwLLTD/g9YEikM9odEEj4HEGQ//bgCfYvLn
UqqO9pAO57hMhzZ0EcYkRJo=
=qxVl
-----END PGP SIGNATURE-----
 
M

Mike Schilling

Jason said:
Is there a specific String I can use to create a file such that
file.exists() will always return false?

Basically, I'm trying to avoid having to check for null all the
time.
So, when I create a new project, I want to set it's starting save
path
(AKA it hasn't been saved yet) to something where file.exists() =
false. String path = new String("") *seems* to work, but I wanted
to
make sure.

File isn't a final class. Create a subclass in which File.exists()
returns false.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top