• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read File on WebSphere Server

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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!
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • 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)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!