Skip to Content
0
Former Member
Nov 30, 2006 at 05:02 AM

Reading a file

51 Views

Hi All,

I need to read contents in a file . I created a Portal Application containing Abstract Portal Component . To the FileInputStream class i passed the filename as parameter. But when i execute it, it throwing file not foud exception.

Also i tried by giving the entire file path as Parameter to the FileInputStream class . Its giving the same error.

When i tried the sample program by creating a simple java application , its working fine.

Here is my code :

{

String thisLine;

FileInputStream fin;

try {

fin = new FileInputStream("../sample.tsv");

BufferedReader myInput = new BufferedReader(new InputStreamReader(fin));

while ((thisLine = myInput.readLine()) != null)

{

StringTokenizer st = new StringTokenizer(thisLine, "\t");

while (st.hasMoreTokens())

{

String key = st.nextToken();

response.write(key + "\n");

}

}

}

catch (Exception be) {

response.write("The Exception is :"+ be); }

}

Need help regarding this?

Regards,

Eben