当前位置: 技术问答>java相关
读取外部文本文件时发生的错误!!!
来源: 互联网 发布时间:2015-01-19
本文导语: 我编写如下代码读取同一目录下名为prop.txt的文本.程序不能通过编译,错误如下: 500 Servlet Exception java.lang.NullPointerException at java.io.Reader.(Reader.java:64) at java.io.InputStreamReader.(InputStreamReader.java:89) at java.io.InputStreamRe...
我编写如下代码读取同一目录下名为prop.txt的文本.程序不能通过编译,错误如下:
500 Servlet Exception
java.lang.NullPointerException
at java.io.Reader.(Reader.java:64)
at java.io.InputStreamReader.(InputStreamReader.java:89)
at java.io.InputStreamReader.(InputStreamReader.java:78)
at java.util.Properties.load(Properties.java:189)
at _jsp._MyTest._Exercises._AppTest__jsp._jspService(/MyTest/Exercises/AppTest.jsp:16)
at com.caucho.jsp.JavaPage.service(JavaPage.java:87)
at com.caucho.jsp.JavaPage.subservice(JavaPage.java:81)
at com.caucho.jsp.Page.service(Page.java:407)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:136)
at com.caucho.server.http.Invocation.service(Invocation.java:259)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:146)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:238)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:157)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 1.3.b1 (built Mon Jan 29 19:25:51 PST 2001)
我感觉程序是程序未能发现prop.txt文件,但我不知该如何解决,请教大家!!!
附prop.txt
count:1
color:green
代码如下:
请朋友多多指教!!!
500 Servlet Exception
java.lang.NullPointerException
at java.io.Reader.(Reader.java:64)
at java.io.InputStreamReader.(InputStreamReader.java:89)
at java.io.InputStreamReader.(InputStreamReader.java:78)
at java.util.Properties.load(Properties.java:189)
at _jsp._MyTest._Exercises._AppTest__jsp._jspService(/MyTest/Exercises/AppTest.jsp:16)
at com.caucho.jsp.JavaPage.service(JavaPage.java:87)
at com.caucho.jsp.JavaPage.subservice(JavaPage.java:81)
at com.caucho.jsp.Page.service(Page.java:407)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:136)
at com.caucho.server.http.Invocation.service(Invocation.java:259)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:146)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:238)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:157)
at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Resin 1.3.b1 (built Mon Jan 29 19:25:51 PST 2001)
我感觉程序是程序未能发现prop.txt文件,但我不知该如何解决,请教大家!!!
附prop.txt
count:1
color:green
代码如下:
请朋友多多指教!!!
|
与Jsp同目录?应该与Sevlet执行路径同目录好像,例如一般的:
web-infclass...
web-infclass...