Reputation: 1
i have this code
public ArrayList<String> getMail() {
ArrayList<String> i = new ArrayList();
try {
int j = 0 ;
FileReader file = new FileReader("emaillist0.txt");
BufferedReader lerArq = new BufferedReader(file);
String linha = lerArq.readLine();
System.out.println("tp aqio ´prra");
while (linha != null) {
i.add(j, linha);
j++;
linha = lerArq.readLine();
}
System.out.println(i.size());
file.close();
return i;
} catch (IOException e) {
System.err.printf( e.getMessage());
return null;
}
}
this problem is when i execute this code in apache tomcat throws this error
emaillist0.txt (The system cannot find the file specified)java.lang.NullPointerException but when i execute this code in a java application work perfectly
Upvotes: 0
Views: 256
Reputation: 771
use absolute path instead of file's name, or move your file into bin directory of tomcat (of course it depends on your OS)
Upvotes: 1