Title: RE: outputting a fileinputstream

To add to Craig's statements, I would also chain a buffered reader to the FileReader for enhanced efficiency:

File file = new File("./public_html/xml/cc.xml");
BufferedReader fis = new BufferedReader(new FileReader(file));

Good luck!

Regards,

Andrew Glover
Web Developer
Origin Technology in Business
3299 K. St. NW Suite 300
Washington, DC  20007
Office: 202-295-2147


Paul Beer wrote:

> I am trying to load an xml packet off a local directory and display it in a
> jsp template... to no avail... could someone lok at this code and let me
> know why it displays nothing ?  when i do a string.length() i get 3451 so I
> know it is reading the stream... I just cant output it in JSP.
>
> thanks,
> paul
>
> code:
>

It might help if you actually read in the data you are talking about, as well as
closed the input file :-).

>
> File file = new File("./public_html/xml/cc.xml");
> FileInputStream fis = new FileInputStream(file);
> byte[] data = new byte[fis.available()];
>

    fis.read(data);
    fis.close();

> String strData = new String(data);
> out.println(strData);
>

One other thing you should do is use a FileReader instead of a FileINputStream,
since you are dealing with text.  Otherwise, you're likely to have problems with
unusual character sets.

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to