Larry: When you ran the webapp, the container has a _different_ view of the file system. The "root" of the file system for the web application will the root of your web app.
The class path you are describing plays no role in finding the program.xmlfile when you try to open a file the way you are doing. If you want the classpath to play a role on how to find your file, take a look at: http://java.sun.com/j2se/1.5.0/docs/api/ java.util Class ResourceBundle Hopes this helps. hff On 3/20/07, Zhang, Larry (L.) <[EMAIL PROTECTED]> wrote:
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: <[EMAIL PROTECTED] language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <[EMAIL PROTECTED] import="java.io.File,java.io.FileInputStream"%> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Sincerely, Harring Figueiredo Sr. Software Engineer Email: [EMAIL PROTECTED] Telephone: 941-256-0600 "We never become truly spiritual by sitting down and wishing to become so. You must undertake something so great that you cannot accomplish it unaided."