This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Servlets and the fly likes two different results Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "two different results " Watch "two different results " New topic

two different results

kashif iftikhar
Ranch Hand

Joined: Aug 21, 2001
Posts: 43
i am getting two different result from almost same programs on winnt.
program 1.
String file = "C:\abc.txt";
File name = new File(file);
System.out.print("it is a file")
System.out.print("file does not exists")
its out put is "file does not exists"

program 2.
i use same code on JSP and get file path through fileDialog box and it outputs "file exists"
why two different outputs ?
Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
dear khasif,
try hard coding the full path in your second code i.e via JSP,I think it should give u file not exists if if r not having any file by that name.Remember a file class object doest not creates a file but only captures the path leading to that file.If u want to create a file u need to use fileoutputstream or random acess,which internally may be happening when u r giving path by file dialogbox.
Don't get me started about those stupid light bulbs.
subject: two different results