Last active
November 7, 2019 00:35
-
-
Save david-botelho-mariano/28cc57fc1e0b4b05bcb71db330075802 to your computer and use it in GitHub Desktop.
Leitura de diretorios de forma recursiva usando JAVA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pacote; | |
import java.io.File; | |
public class ClasseMain { | |
public static void adicionarNoBanco(String pathArquivo) { | |
System.out.println(pathArquivo); | |
//merge e commit | |
} | |
public static void getConteudoDiretorio(File diretorio) { | |
try { | |
File[] arquivos = diretorio.listFiles(); | |
for (File arquivo : arquivos) { | |
if (arquivo.isDirectory()) { | |
getConteudoDiretorio(arquivo); | |
} else { | |
adicionarNoBanco(arquivo.getCanonicalPath()); | |
} | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public static void main(String[] args) { | |
File diretorioBase = new File("C:\\Users\\David B M\\Desktop\\Desk\\Trabalhos[tasks]\\xml2dict2obj\\xmls"); | |
getConteudoDiretorio(diretorioBase); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment