commit 8bc22fbd28a0a0e3ee641d2aabf5d5fbb1b82169 Author: michaelpaliz Date: Wed Oct 12 01:10:21 2022 +0200 changes diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..08295a0 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Ejercicio_6 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa30804 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +asdf a diff --git a/bin/Ejercicio6/Ejercicio6.class b/bin/Ejercicio6/Ejercicio6.class new file mode 100644 index 0000000..b91e0dc Binary files /dev/null and b/bin/Ejercicio6/Ejercicio6.class differ diff --git a/bin/Ejercicio6/destino b/bin/Ejercicio6/destino new file mode 100644 index 0000000..8fa1018 --- /dev/null +++ b/bin/Ejercicio6/destino @@ -0,0 +1 @@ +que masInterruptedException \ No newline at end of file diff --git a/bin/Ejercicio6/origen b/bin/Ejercicio6/origen new file mode 100644 index 0000000..8fa1018 --- /dev/null +++ b/bin/Ejercicio6/origen @@ -0,0 +1 @@ +que masInterruptedException \ No newline at end of file diff --git a/bin/module-info.class b/bin/module-info.class new file mode 100644 index 0000000..64cf0bf Binary files /dev/null and b/bin/module-info.class differ diff --git a/src/Ejercicio6/Ejercicio6.class b/src/Ejercicio6/Ejercicio6.class new file mode 100644 index 0000000..fa391bb Binary files /dev/null and b/src/Ejercicio6/Ejercicio6.class differ diff --git a/src/Ejercicio6/Ejercicio6.java b/src/Ejercicio6/Ejercicio6.java new file mode 100644 index 0000000..36d20ad --- /dev/null +++ b/src/Ejercicio6/Ejercicio6.java @@ -0,0 +1,79 @@ +package Ejercicio6; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.Scanner; + +public class Ejercicio6 { + + // Crea un programa Java MiCopy que copie un archivo. Por ejemplo “MiCopy + // FicheroOrigen.dat FicheroDestino.dat”. + // El programa tendrá que mostrar por pantalla el tanto por cien que lleva + // realizada de la copia y deberá también mostrar algún tipo de animación + // (similar a wget). + // Cuando termine la copia se mostrará un mensaje de fin de la copia. + private static String formatter ="\033[H\033[2J | Descarga %2.2f%% %1s %s | \n"; + private static Scanner sc = new Scanner(System.in); + + public static void main(String[] args) { + + + System.out.println("Introduce la ruta de origen"); + String origen = sc.nextLine(); + System.out.println("Introduce la ruta de destino"); + String destino = sc.nextLine(); + + copiar(origen, destino); + } + + + public static void copiar(String origen, String destino) { + + File sourceFile = new File(origen); + File destinationFile = new File(destino); + + + try ( + FileInputStream inputStream = new FileInputStream(sourceFile); + FileOutputStream outputStream = new FileOutputStream(destinationFile)) { + + long lenOfFile = sourceFile.length(); + long currentBytesWritten = 0; + int data; + StringBuilder sb = new StringBuilder(); + + while ((data = inputStream.read()) != -1) { + outputStream.write(data); + String symbol = "*"; + currentBytesWritten += 1; + + for (int i = 0; i <= 1; i++) { + + for (int j = 0; j <= i; j++) { + sb.append(symbol); + System.out.printf(formatter, 100 * ((double) currentBytesWritten) / ((double) lenOfFile), " ", sb.append(sb.charAt(j))); + } + Thread.sleep(40); + System.out.flush(); + } + System.out.println("Copia completada exitosamente!"); + + } + + } catch (InterruptedException | IOException io) { + io.printStackTrace(); + } + + + } + + +} diff --git a/src/Ejercicio6/destino b/src/Ejercicio6/destino new file mode 100644 index 0000000..8fa1018 --- /dev/null +++ b/src/Ejercicio6/destino @@ -0,0 +1 @@ +que masInterruptedException \ No newline at end of file diff --git a/src/Ejercicio6/origen b/src/Ejercicio6/origen new file mode 100644 index 0000000..8fa1018 --- /dev/null +++ b/src/Ejercicio6/origen @@ -0,0 +1 @@ +que masInterruptedException \ No newline at end of file diff --git a/src/module-info.java b/src/module-info.java new file mode 100644 index 0000000..1a88c0d --- /dev/null +++ b/src/module-info.java @@ -0,0 +1,9 @@ +/** + * + */ +/** + * @author michael + * + */ +module Ejercicio_6 { +} \ No newline at end of file