• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Cannot get the complete filename

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search for the getAbsolutePath method.
 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay! Anyway, thanks so much for your replies. It did help a lot.
God bless.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic