• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

two different results

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am getting two different result from almost same programs on winnt.
program 1.
String file = "C:\abc.txt";
File name = new File(file);
if(name.isFile())
System.out.print("it is a file")
else
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 ?
------------------
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic