Java Bug? "new File(...)" deletes file?

b4u

Golden Member
Nov 8, 2002
1,380
2
81
Hi,

I'm using Eclipse 3.1 and have J2SDK 5.0 installed on my computer.

My question is:

When using the code:

import java.io.File;

String fileName = "c:/x/anyfile.txt";
File f = new File(fileName);

Instead of just creating an instance of File using the name I provided, the code just deletes it entirely from the disc ... any bug, or is there anything obvious I'm missing?

Thanks
 

Thyme

Platinum Member
Nov 30, 2000
2,330
0
0
Interesting. Sure nothing else in the code is doing it? Post complete code?
 

znaps

Senior member
Jan 15, 2004
414
0
0
I doubt that's happening, at least by the code that you posted - creating a File object in itself doesn't do anything.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
That's definitely odd :p a File object has no actual connection to the file system.
 

b4u

Golden Member
Nov 8, 2002
1,380
2
81
AH! Found the code that was doing the dirty job!

Nothing better than take some time off, and return latter to find those difficult problems that are in front of our eyes and we just can't find ...

Better open my eyes at work lol

Thanks for listening :)