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
使用绝对路径而不是文件名,或将文件移到tomcat的bin目录中(当然,这取决于您的操作系统)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.