Skip to Content
author's profile photo Former Member
Former Member

Reading file

Hi. I would like to read a txt file and display the content. i am relatively new in this area and need some help. i wrote some codes but it complained that the system couldn't find the file. i placed the txt file within the irj/resources/myproj folder, and also in the same folder with the jsp file that reads it. yet, the system couldn't find the file. may i know where to place the file and how to read the file? appreciate if anyone can provide some sample code for reference. thank you.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2004 at 08:41 AM

    You can try this (the neutrally Java way):

    InputStream in = null;

    in = MyClass.class.getResourceAsStream("myTxt.txt");

    MyClass and myTxt are placed in the same package of Your sourcefolder.

    To make sure that Your txt file is also in the binaryfolder You have to mark the chekbox in eclipse:

    window->preferences->SAP Portal... -> Yes, I want the non Java sources...

    Walter

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I think, the reason is because the compiled JSP isn't in Your .../work directory.

      You can try the ComponentProfile object (componentProfile = componentContext.getProfile();)

      I can hardly remember that it is possible (EP5) to get some files from the profiles directory....

      Keep on trying...

      Walter

  • author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2004 at 05:36 AM

    hi. thanks for the guidelines. it turns out that it works when i specify it like this:

    BufferedReader in = new BufferedReader(new FileReader("C:
    mytext.txt"));

    instead of "C:/mytext.txt"

    another question, have anyone tried passing data using bean and profile?

    In my DynPage, i used

    profile.putValue("aV", aValue)

    Object o = profile.getValue("aV"); -> aValue is a bean, i can get the value

    But in the JSP page where the DynPage directs to, no value. i have specified in my jsp page -> <jsp:useBean id="custList" scope="application" class="PF.CustomerList" />

    any idea? thanks.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.