Boa tarde a todos,
gostaria de uma ajuda no seguinte:
Preciso copiar um arquivo de um diretório para outro. Abaixo seguem os códigos que estou usando e os problemas ocorridos:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class CopiaArquivo {
public static void main(String[] args) throws IOException {
FileChannel oriChannel = new FileInputStream("C:\\diretorio\\DLLator2.vbs").getChannel();
FileChannel destChannel = new FileOutputStream("C:\Diretorio1\Diretorio2\Diretorio3 ").getChannel();
destChannel.transferFrom(oriChannel, 0, oriChannel.size());
oriChannel.close();
destChannel.close();
}
}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class CopiaArquivo {
public static void main(String[] args) throws IOException {
File file = new File("C:\\diretorio\\DLLator2.vbs");
File dir = new File("C:\Diretorio1\Diretorio2\Diretorio3 ");
boolean success = file.renameTo(new File(dir, file.getName()));
if (!success) {
System.out.println("File was not successfully moved");
}else{
System.out.println("File was successfully moved");
}
}
}
Agradeço qualquer ajuda.