Java windows Linus File path problem on exist() or isfile() method
G.Sathish kumar
Ranch Hand
Joined: Jul 27, 2009
Posts: 84
posted
0
Hi
i am using some pdf files need to be opened when user click the link in my web application.
so i need one validation like when no file there in the path the file corresponding name display without link so i use isFile() then exist() method
directory structures
student
web-inf
classes
filedir
some pdf files
so i use application.getContextpath+"//fildir//pdffilesname"
it is working in windows local but when i move this to linus staging is giving problem like the exist method return always false but the file i am able to open through link.
Thanks
Sathish kumar
SCJP, SCWCD
Ernest Friedman-Hill
author and iconoclast
Marshal
Backward slashes won't work on UNIX, and I wouldn't count on doubled forward ones (why are you doing that?) to work either. Use File.separatorChar rather than a hard-coded separator. Also note that UNIX filesystems are case sensitive, while Windows ones aren't always; be sure to use correct letter case.
Ernest Friedman-Hill wrote:Backward slashes won't work on UNIX, and I wouldn't count on doubled forward ones (why are you doing that?) to work either. Use File.separatorChar rather than a hard-coded separator. Also note that UNIX filesystems are case sensitive, while Windows ones aren't always; be sure to use correct letter case.
i have done that but i am not clear with the concept.
when i access the file from web application context like http://sitename/filepath/file.pdf it is working in windows and not working in linux
but in the os context like //directory/file.pdf if i create the file it working both windows(corresponding file path d:/filpath/file.pdf) and linux
please explaing what is the difference why the web application context is not working in linux?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Java windows Linus File path problem on exist() or isfile() method