• 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

Read File on WebSphere Server

 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a class that loads some data from a text file. In WSAD development in we give a FileReader the full d:\path\name.ext and it works fine. When deployed to WebSphere on AIX I don't know how to develop a filespec - fully qualified or relative - that will work.

I'm told that our EAR is deployed to a directory like this:

/opt/WebSphere/AppServer/installedApps/ourAppCell/ourApp.ear

Is it safe to use that as a base and add something like "/config/components/name.ext" on the end? Or is there a WebSphere or J2EE API to get this value dynamically from the container rather than putting it in application configuration? Or is reading a file a totally bad idea?

Thanks!
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

doing IO operations from the ejb container is not allowed by the specification but some app servers allow it, even if websphere allow this(I'm not sure it does) you should avoid it.

About building code that could read a file using relative paths and os independent you may consider using the classloader:



then you may use:



regards.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool. We're also considering posting the file as static content on the web server and getting it via HTTP. We only get it once a day or after a manual cache purge.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic