• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Cannot get the complete filename

 
Ranch Hand
Posts: 185
  • 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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for the getAbsolutePath method.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!