Pessoal peguei esses procedimentos mais não estou conseguindo fazer a chamada do copyDiretorio(File srcDir, File dstDir).
Que tipo de dado eu devo enviar como parâmetro ?
claro que é do tipo file mais não estou conseguindo.
Tentei
File entrada = new File("caminho do arquivo");
File saida = new File("caminho do arquivo");
copyDiretorio(entrada,saida);
Mais não aceita
retorna o seguinte erro
unreported exception java.io.IOException; must be caught or declared to be thown
Ficaria muito grato pela ajuda.
public void copyFile(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
// Copies all files under srcDir to dstDir.
// If dstDir does not exist, it will be created.
public void copyDiretorio(File srcDir, File dstDir) throws IOException {
if (srcDir.isDirectory()) {
if (!dstDir.exists()) {
dstDir.mkdir();
}
String[] children = srcDir.list();
for (int i=0; i<children.length; i++) {
copyDiretorio(new File(srcDir, children[i]),
new File(dstDir, children[i]));
}
} else {
// This method is implemented in e1071 Copying a File
copyFile(srcDir, dstDir);
}
}