Discussions

General J2EE: Problems with reading from flat file

  1. Problems with reading from flat file (4 messages)

    How can I get my web app to read my flat file located in myapp\web-inf directory. Any suggestions would be appreciated.
  2. Problems with reading from flat file[ Go to top ]

    URL url = new URL("http://myApp:80/file.txt);

    BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream()));
    String line = "";
    StringBuffer buffer = new StringBuffer();
    while( (line = reader.readLine()) != null)
      buffer.append( line);
  3. Problems with reading from flat file[ Go to top ]

    I almost forgot, don't place the file under WEB-INF, place it under the document root, or any subfolder under the document root directory. I don't think you can read files under WEB-INF since they are protected.

    SAF
  4. Problems with reading from flat file[ Go to top ]

    SAF, you are right. Files under WEB-INF are protected.
  5. maybe try to get the root context path of the web application then add WEB-INF to the path and pass to a file object