File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java windows Linus File path problem on exist() or isfile() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java windows Linus File path problem on exist() or isfile() method" Watch "Java windows Linus File path problem on exist() or isfile() method" New topic
Author

Java windows Linus File path problem on exist() or isfile() method

G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
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

Joined: Jul 08, 2003
Posts: 24043
    
  13

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.


[Jess in Action][AskingGoodQuestions]
G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
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
 
Similar Threads
Using Thumbnail PDFs
help coroutine
Cross Platform File Path
Creating File object problem
RandomAccessFile