File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
I agree. Here's the link:
subject: two different results
jQuery in Action, 3rd edition