Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Class path basic question and FileInputStream

Zhang, Larry (L.)

2007-03-20

Replies:

I have a program.xml file phycially located in a directory in my web
project class path in WSAD,then in my jsp I am trying to read this file,
I got an error saying the file is not found. Why? When creating File
file = new File("program.xml"); on earth, which directory does JVM tries
to find out the file? Thanks.

P.S. JSP:

<%@(protected)"
 pageEncoding="ISO-8859-1"%>
<%@(protected)"%>
Hello world.<br />
<%
 File file = new File("program.xml");
 // JVM will fine out the file in the build directory instead of
from the class path
 FileInputStream fis=new FileInputStream(file);
 byte b[]=new byte[fis.available()];
 fis.read(b);
 String s = new String(b);
 StringBuffer data = new StringBuffer(s);
 System.out.println("Data:\n " + data.toString() + "\n");
%>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.