Я пытаюсь использовать функцию readFile из суперкласса Container, но вызываю исключение FileNotFound в стеке. Что мне здесь не хватает?
Код: Выделить всё
public static final List readFile(String fileName) throws FileNotFoundException, IOException {
List result = new ArrayList();
try (Scanner s = new Scanner(new File(fileName))) {
while (s.hasNextLine()) {
result.add(s.nextLine());
s.close();
}
return result;
}
}
Код: Выделить всё
public Stack(String fileName) throws FileNotFoundException, IOException {
stack = new ArrayList();
String obj = (String) Stack.readFile(fileName).get(0);
stack.add(obj);
if(obj.startsWith("Stack"))
{
stack.add(obj.substring(4).strip());
}
}
Источник: https://stackoverflow.com/questions/781 ... e-function