throwing exception 'file is not found'
in j2me app
my csv file is in com.school.student package
and the file where i write my code is in the same package 'student'
and the code is:
InputStream is = getClass().getResourceAsStream("CWGData.csv");
StringBuffer sb = new StringBuffer();
try{
int chars, i = 0;
while ((chars = is.read()) != -1){
sb.append((char) chars);
}
System.out.println(" ---------- CSV file is: ---- " + sb.toString());
return sb.toString();
}catch (Exception e){}
return null;
and it is throwing exception of file not found..
i dont understand what's the problem ??
Re: throwing exception 'file is not found'
Is that csv file is inside the resource folder?
or where is the file?
What the exact exception you are getting, is this IOException ?
Re: throwing exception 'file is not found'
i have tried it both the ways by placing it into res folder or into com.school.student package also.
and the exception is java.lang.NullPointerException
Re: throwing exception 'file is not found'
[QUOTE=poojs;727352]i have tried it both the ways by placing it into res folder or into com.school.student package also.
and the exception is java.lang.NullPointerException[/QUOTE]
That means your path is not correct..
Have you add the res folder to the project?
Re: throwing exception 'file is not found'
Re: throwing exception 'file is not found'
try utStream is = getClass().getResourceAsStream("\CWGData.csv");
put the file in res folder.
once the jar is made, check if contains the required res file in it?
thanks,
~Amitabh
Re: throwing exception 'file is not found'
[QUOTE=poojs;727750]yes i have tried it[/QUOTE]
I guess you have not add the res folder to the project.have you?
if yes then check the name of the file.
Try "/" before the name of the file.
Also you try to read the text file first and draw the text on the form though,