Java file read path question and answer

Source: Internet
Author: User
Tags relative
Ask:
File File=new file (filepath);
BufferedReader br = new BufferedReader (new FileReader (file));
Here's the filepath I assign to:/jsp/mytest/newstemplate.html
But when the program executes, it prompts
Java.io.FileNotFoundException: \jsp\mytest
Ewstemplate.html
When I wrote FilePath as an absolute path: c:\\www\\jsp\\ ... , the program can execute.

If the JSP file currently executing is xxx.jsp
Then the file name for the assignment file cannot be:.. /yyy.jsp?

If you do a news system, the user has installed, do not know the user installed in which directory. If you want to read the program
The file in a directory, only know the relative, do not know the user's absolute directory, this time how to do?
Do I have to use the absolute path with the letter?

For:
Relative path is OK, but not your JSP put the relative path, is the JSP engine to execute this JSP compiled into a servlet
The path to the root. For example, resin,file f = new File ("a.htm");
This a.htm is under the resin installation directory.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.