aspose file tools*
The moose likes Beginning Java and the fly likes Cannot get the complete filename Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cannot get the complete filename" Watch "Cannot get the complete filename" New topic
Author

Cannot get the complete filename

Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
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

Joined: Jul 09, 2007
Posts: 24
Search for the getAbsolutePath method.
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
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

Joined: Jul 09, 2007
Posts: 24
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

Joined: Aug 17, 2007
Posts: 185
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

Joined: Aug 17, 2007
Posts: 185
By the way I am using Apache Commons File Upload.
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
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

Joined: Jul 09, 2007
Posts: 24
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

Joined: Aug 17, 2007
Posts: 185
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
 
subject: Cannot get the complete filename
 
Similar Threads
Writing File Paths to a File
How to include full file path in io?
Issues with IE and Mozilla Firefox
I/O operation in jsp
Canonical vs Absolute