I can not pass a method to get the name of the files in a folder.
I have the following code:
inicializar.addWindowListener(new WindowListener(){
@Override
public void windowOpened(WindowEvent arg0){
DefaultListModel dlm = new DefaultListModel();
JList lstvRel = new JList();
lstvRel.setModel(dlm);
ListarArquivos l = new ListarArquivos();
dlm = l.listar(); //Erro nesta linha!!
for(int i = 0; i < l.listar().size(); i++){
lstvRel.getModel().getElementAt(i).toString();
}
}
And the class:
public class ListarArquivos {
public void listar() {
File dirArquivos = new File("C:\Users\lbell\Desktop\Turbo - teste");
File[] Arquivos = dirArquivos.listFiles((File b) -> b.getName().endsWith(".xls") ||
b.getName().endsWith(".xlsx") ||
b.getName().endsWith(".xlsm") ||
b.getName().endsWith(".xlsb") ||
b.getName().endsWith(".ppt"));
}
}