How do I read a file in App Engine?

后端 未结 5 1683
灰色年华
灰色年华 2021-01-01 20:44

I have a file at /WEB-INF/config.txt on app engine. What is the path to the file on app engine?

eg: new File(/*What path do i put here?*/)

5条回答
  •  情深已故
    2021-01-01 21:39

    There's some documentation at appengine how to add resources to your project. Check out the part. Some further information can be read in the description of the appengine sandbox.

    When the resources are added to your project you can use the following code to read their content:

    File f = new File("path/below/my/project/directory/config.txt");
    InputStream in = new FileInputStream(f);
    

    In the above example the 'path' directory is below your project's 'war' directory.

提交回复
热议问题