Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws InterruptedException, IOException {
- ArrayList<String> selectFiles = new ArrayList<>();
- File folder = new File("путь");
- File[] listOfFiles = folder.listFiles();
- for (File f : listOfFiles) {
- selectFiles.add(f + "");
- }
- File source = new File(" " + selectFiles);// ПОЛУЧАЮ СПИСОК ФАЙЛОВ ПРИСВАИВАЮ ПЕРЕМЕННУЮ С ФАЙЛАМИ
- File dest = new File("путь");// ПРОПИСЫВАЮ ПУТЬ КУДА КОПИРОВАТЬ
- copy(source, dest);
- }
- public static void copy(File source, File dest) throws IOException {
- Files.copy(source.toPath(), dest.toPath());
- }
- private static void copyDir(String sourceDirName, String targetSourceDir) throws IOException {
- File folder = new File(sourceDirName);
- File[] listOfFiles = folder.listFiles();
- Path destDir = Paths.get(targetSourceDir);
- if (listOfFiles != null)
- for (File file : listOfFiles)
- Files.copy(file.toPath(), destDir.resolve(file.getName()), StandardCopyOption.REPLACE_EXISTING);
- }
- for (File f : listOfFiles) {
- Files.copy(f.toPath(), new File("путь" + File.separator + f.getName()).toPath());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement