As the App Engine documentation notes, you can use many of the file access
facilities of the Java API.
The methods java.lang.Class.getResource(?:AsStream)? and
java.lang.ClassLoader.getResource(?:AsStream)? are special cases. While the
documentation for Class.getResourceAsStream is quite somewhat convoluted,
it is only logical that it searches relative to the .class file you used:
> InputStream stream = MyClass.class.getResourceAsStream("myFile");
This is true of all Java environments.
To access files outside the classpath, I suggest using the java.io family
of classes.
On Monday, December 17, 2012 3:57:12 AM UTC+1, Michael Hermus wrote:
>
> Hi,
>
> I have a .txt file which I need to load as Resource using
> getResourceAsStream(). The docs (
> https://developers.google.com/appengine/kb/java) say:
>
> It is possible to read from a file which is uploaded as part of your
>> application provided that it is in the following locations:
>>
>> - war/WEB-INF
>> - in a location matching the <resource-files> pattern in
>> appengine-web.xml (which by default includes everything)
>>
>>
> I have no <resource-files> entry (so it should use the default), and I put
> this file in both the war/WEB-INF directory AND the war root directory:
> AppEngine CANNOT load the resource. However, if I put the file in
> war/WEB-INF/classes, the system CAN load the resource. I spent way too much
> time trying to get this to work; perhaps I misunderstand something, but if
> not, please update the docs, or make this work as documented.
>
> Mike
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine/-/Ea8lNIx-B8UJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.