File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot get the complete filename

 
Darren Alexandria
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am supposed to get the complete filename where I got a particular file.
Example:

C:/Documents and Settings/User Files/User/Webapps/MyWebapp/test.txt

I am using this code:


But it only outputs "test.txt".
How can I get the whole path?

Thanks.
 
Kail Limas
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for the getAbsolutePath method.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Thanks for your reply. As you suggested, I used the getAbsoltuePath method and modified the code to this:



but I got the wrong output:

Field = C:\Tomcat 5.5.23\bin\test.txt
 
Kail Limas
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show me the code that creates fi.getName? Could be that the problem is that the file is generatet in the current location, not where you want it to be created.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the code where I got the "fi" variable:



The file is saved on my desktop.

Thanks so much for your help. I really appreciate it.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way I am using Apache Commons File Upload.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just checked the API of Apache Commons File Upload and from that my code supposed to give me the right output.

When I use Mozilla Firefox my code's output is wrong but in IE my code is right.

How can I resolve that?
 
Kail Limas
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I've got no idea there. I'm pretty new to java myself and still learning, sometimes with solving questions like these^^ But I've never worked with the File Uploader, and if it's shown correctly under IE but not under Firefox I can't help you.

It probably has something to do with the different systems behind saving a file the two use. But I have no idea what that is.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay! Anyway, thanks so much for your replies. It did help a lot.
God bless.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic