I never thought about the write implications. I am only interested in reading 
the file.

to that end, I tried this and it 'works' for my needs. Of course I will 
probably just put the data into the database and eliminate the need to read a 
file directly.

ERXResourceManager resMgr = (ERXResourceManager) 
ERXApplication.application().resourceManager(); 
String mapFilePath = resMgr.pathURLForResourceNamed("AllCountries.txt", null, 
null).toString();
                        
mapFilePath = mapFilePath.replace("file:/", "/");
System.out.println("         path is     : " + mapFilePath);
                        
File f = new File(mapFilePath);

I see that pathForResourceNamed is deprecated. it is recommended to use 
pathURLForResourceNamed. Do I understand that I must clean up the path string 
or is there a direct method that returns the path?

Thanks,  Ted


--- On Fri, 9/2/11, Mike Schrag <[email protected]> wrote:

From: Mike Schrag <[email protected]>
Subject: Re: path in .java question
To: "Ted Archibald" <[email protected]>
Cc: "Theodore Petrosky" <[email protected]>, [email protected]
Date: Friday, September 2, 2011, 11:07 AM

In the general case, if it's a WebServerResource, you can't count on being able 
to write to it because it could live on a completely different machine that is 
serving your webserver static resources in a split install.
ms

On Sep 2, 2011, at 10:57 AM, Ted Archibald wrote:
You should use WOResourceManager/ERXResourceManager

On Fri, Sep 2, 2011 at 8:53 AM, Theodore Petrosky <[email protected]> wrote:

I want to read a file when my app launches:



File f = new File("AllCountries.txt");



I don't understand the path! if AllCountries.txt lives in the 
WebServerResources folder, what is the path I should use to access it?


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to