To read the files return a list you can use the following method:
private List<String> lerNomesArquivo(String caminho) {
File pasta = new File(caminho);
List<String> nomes = new ArrayList<>();
for (String nome : pasta.list()) {
if (nome.endsWith(".xml")) {
nomes.add(nome);
}
}
return nomes;
}
To use the names for popular:
private void popularTabela() {
List<String> arquivos = this.lerNomesArquivo("C:/Users/Meu Usuário/Minha pasta");
DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
int rowCount = modelo.getRowCount();
// Remove linhas atuais
for (int i = rowCount - 1; i >= 0; i--) {
modelo.removeRow(i);
}
for (String arquivo : arquivos) {
String[] linha = {arquivo};
modelo.addRow(linha);
}
}
What you’ve tried to do?
– user28595
So I don’t really know how to do it, what I know for example is to take data from the database and popular to Jtable, but in case now the XML files are in a folder on the server.
– Prostetnic Vogon Jeltz
It would be interesting to add an attempt, otherwise the question falls too wide.
– user28595