|
|
|
@ -4,10 +4,14 @@ import java.io.BufferedInputStream;
@@ -4,10 +4,14 @@ import java.io.BufferedInputStream;
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.nio.file.DirectoryNotEmptyException; |
|
|
|
|
import java.nio.file.DirectoryStream; |
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.nio.file.StandardCopyOption; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.Enumeration; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.zip.ZipEntry; |
|
|
|
|
import java.util.zip.ZipFile; |
|
|
|
|
|
|
|
|
@ -72,13 +76,13 @@ public class GitListener {
@@ -72,13 +76,13 @@ public class GitListener {
|
|
|
|
|
try { |
|
|
|
|
NetService.download(opt.getZipLink(), opt.getDownloadPath()); |
|
|
|
|
extract(); |
|
|
|
|
move(); |
|
|
|
|
move(opt.getSourcePath(), opt.getDestinationPath()); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
Thread.sleep(2000); |
|
|
|
|
Thread.sleep(10000); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
System.out.println("Проспал!!! Ошибка!!!"); |
|
|
|
|
e.printStackTrace(); |
|
|
|
@ -132,13 +136,41 @@ public class GitListener {
@@ -132,13 +136,41 @@ public class GitListener {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* перемещаем файлы из директории source в target |
|
|
|
|
*/ |
|
|
|
|
public void move() throws IOException { |
|
|
|
|
Path source = Path.of("C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\unzip\\molokoin\\molokoin-client"); |
|
|
|
|
Path target = Path.of("C:\\Users\\Strannik\\Documents\\esoe\\code\\sourceListener\\out\\war\\www\\html"); |
|
|
|
|
public void move(String sourceString, String targetString) { |
|
|
|
|
Path source = Path.of(sourceString); |
|
|
|
|
Path target = Path.of(targetString); |
|
|
|
|
System.out.println("Перемещение контента ... "); |
|
|
|
|
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING); |
|
|
|
|
System.out.println("sourceString: " + sourceString); |
|
|
|
|
System.out.println("targetString: " + targetString); |
|
|
|
|
try { |
|
|
|
|
//просмотр содержимого папки target
|
|
|
|
|
try (DirectoryStream<Path> files = Files.newDirectoryStream(target)) { |
|
|
|
|
for (Path path : files){ |
|
|
|
|
System.out.println("Очистка пути: " + path);//вывод содержимого в консоль
|
|
|
|
|
//очистка папки
|
|
|
|
|
if(Files.isDirectory(path)){ |
|
|
|
|
deleteDirectory(path); |
|
|
|
|
}else{ |
|
|
|
|
Files.delete(path); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING); |
|
|
|
|
System.out.println("Метод move() успешно выполнен!!!!"); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
System.err.println("Ошибка в методе move():" + e.getMessage()); |
|
|
|
|
System.err.println("out >>>>>>>>>>>" + e.getLocalizedMessage()); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void deleteDirectory(Path directory) throws IOException { |
|
|
|
|
Files.walk(directory) |
|
|
|
|
.sorted(Comparator.reverseOrder()) |
|
|
|
|
.map(Path::toFile) |
|
|
|
|
.forEach(File::delete); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException { |
|
|
|
|