• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading files from servlet

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
I'm using tomcat. I have a function which reads a XMl file and sets the required variables.I need to provide the file name to the file as a string. when I try to give a relative path tomcat gives me the following error
I do this :
===========
File objXML = new File("Metadata.xml");
System.out.println("\nThe absolutepath of the file is : "+objXML.getAbsolutePath());
And it returns this:
====================
The absolutepath of the file is : D:\TomCat\bin\DATMetadata.xml
but the file is existing in some other How to set a directory from where it reads the files.
rgds
Kiran Mohan Nori
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what about using the dual argument constructor for File?

File f = new File(path, filename);
 
kiran nori
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't hardcode the path as my program can be deployed in any directory.
rgds
Kiran
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic