From 6b8b3fdfe4d4e76ec392b606e0e7eb22f599692e Mon Sep 17 00:00:00 2001 From: jandroalbus Date: Thu, 6 Oct 2022 13:37:20 +0200 Subject: [PATCH] Commit inicial --- MiCopyFicheros/.classpath | 10 +++ MiCopyFicheros/.project | 17 ++++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 14 ++++ MiCopyFicheros/README.md | 36 +++++++++ .../bin/MiCopyFicheros/MiCopyFicheros.class | Bin 0 -> 2822 bytes .../src/MiCopyFicheros/MiCopyFicheros.java | 76 ++++++++++++++++++ 7 files changed, 155 insertions(+) create mode 100644 MiCopyFicheros/.classpath create mode 100644 MiCopyFicheros/.project create mode 100644 MiCopyFicheros/.settings/org.eclipse.core.resources.prefs create mode 100644 MiCopyFicheros/.settings/org.eclipse.jdt.core.prefs create mode 100644 MiCopyFicheros/README.md create mode 100644 MiCopyFicheros/bin/MiCopyFicheros/MiCopyFicheros.class create mode 100644 MiCopyFicheros/src/MiCopyFicheros/MiCopyFicheros.java diff --git a/MiCopyFicheros/.classpath b/MiCopyFicheros/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/MiCopyFicheros/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/MiCopyFicheros/.project b/MiCopyFicheros/.project new file mode 100644 index 0000000..177fb2f --- /dev/null +++ b/MiCopyFicheros/.project @@ -0,0 +1,17 @@ + + + MiCopyFicheros + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/MiCopyFicheros/.settings/org.eclipse.core.resources.prefs b/MiCopyFicheros/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/MiCopyFicheros/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/MiCopyFicheros/.settings/org.eclipse.jdt.core.prefs b/MiCopyFicheros/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/MiCopyFicheros/.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/MiCopyFicheros/README.md b/MiCopyFicheros/README.md new file mode 100644 index 0000000..1fba4e5 --- /dev/null +++ b/MiCopyFicheros/README.md @@ -0,0 +1,36 @@ +# README.md + +## Titulo +MyCopy Ficheros + +## Autor +Alejandro Javier Albus 2CFGS DAM + +## Enunciado +ACTIVIDAD 06 : 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. + +## Uso +Debe introducir en los atributos del programa el archivo a copiar (IN) y el destino de dicho archivo (OUT). +Dicho archivo se copiará integramente. + +## Ejemplo de ejecución + +Los cuadrados iran apareciendo desde 0. + +
+
+> Empezando copia ...
+[■■■■■■■■■■] 100%
++ Se ha finalizado la copia correctamente
+
+
+ +## Dependencias +Uso de librerias externas: +* java.io.* + +## Licencia +Uso libre \ No newline at end of file diff --git a/MiCopyFicheros/bin/MiCopyFicheros/MiCopyFicheros.class b/MiCopyFicheros/bin/MiCopyFicheros/MiCopyFicheros.class new file mode 100644 index 0000000000000000000000000000000000000000..efb0bdfdbf1f9e9632764e8b7c1217dc9a69827d GIT binary patch literal 2822 zcmbtWTXz#x6#hlTcFWlg?^p&ShV|{q4Qa>92o(|096A z@TGzVfzA;#?G(=snb|qRbxM6JrwW1s&GY(Mz0cC^eBbEIypi<;!grds>FpB;q`D^r zf@vpbs0bjcA%w8N+F{c+j+F~DhI>Mvu?&IOu#?rT3Eeg2ytWwh=FF17=HZoI{{>=z z4hp(y3$&%ChOdDc_gvG?4@dy&p>tWI=$VdPQV1vb>f$k@fQM=lJ#pdx|IQavfK zuBJ{BBv{gRXGi}EYM@1Lfqqqs(3Q{YIX#9N1GYT5E zV+RY!DYKqhtDzF>7;{>SW*~wd=3L#EJX9ze7nm<6nRSY$p6u=IRndo=73`|Zb)Bk) zTO@@_QChP|tH5pzw_y(pvFJK^*C>_73^!{q&3RU5D3!@{PlVVPd;))}=*OK3Sa@}{ ze`1al=QMT>>poPn45P@xOdXZP-YwAX6YF=$@v`li1!KALRP4tAnU*y9ug@w?I*-VH zV0I!nB(PoGksLRYb9!>tv~|n8pfhGmuZ5j;T$k;q7YLi}mcU^RM`XK&vX)cgN*4|* zxJO{qH7ps5x^B7X8M$RVgsr=IHs1PG+DRaqGo>5HJuln#nyFg935Z#NHOm?Et4p9k zHfVgsYF%ZL%Jvm|^`*y6Ve*&ZkI6{Z`CJV?#hb=GJ$q(EFZu_Gf)NGNE0R^ks^B4k zE!QH*SeB93twA?mmK-hfc~)h|YK6k%j^&Z*&O|_Tf#2WzLP7p& z6Z#3SdOJ`yt(@Vin1U&@JumBOD&0LHS1b($kRio2ik6%qy>M1<1s`4z_BPf%|lPYHMh=y}u8pC?AXxKS{o_aeqkJsC&MKT~w zJgVU_JT4INoT|J)OX_+RHtUo0Iwj#ht>GCwORtt;=e;@qmdMDB=QKQz7g%AX@=VD; zy(JB#_Ies3c#-CsB6yjfqy+M+jO8_fL~0fJtB50bgYw(t>F}0@x8)%a@(%%`agFLN z67n2Rx5#cmKR0e(U@D^3E#4+vwH@!EV{=uoU4uD)7@W~vu0-Ugx~a>3yxMwYF|tp|iGS7vIpU4Ux59ZJzk=V;_C-X#<)8s7-*TIaXyjX~ zjWslJ7R4H@rBpM=($qR>M(n3?X|51kKfHw2$=HTP#7CBpnB2LDO~;ndH5uEwh;9AB zo}V%J9d3;6te`irC$xaAt)X@JQ>;pb5`ENlZ!LC6Yp>`pLZD>IcXSX6wjZW%p!VorN zjB8W40a*|BZ%sH&oqHL68}7$(jB~GxQrmHYWbDEY z+=mI$HbgY{;{nn*N&PJdU7_o+f(I2$DQH!YP|!t&#}piGZ1{^PRe4p=gCz4TEy!pV z+B?2N;}T9zF5=Wr&FWq49f`|0y|1}vPcWA24=rJKatTwDi626Xm?u>^kc&dVn{gJ?)=mHW_HLg^JUWPu_0Azl~JgfeqM;4qj}BN%{%iVh>^; ziu|5u0=`Dtm!7SLig!qyd=~I7M?6{aKHlS~fmYt&c!EAU@CrV_hopKlF5x4lgclrg z_?V+Gy`07;94YiQj!!v?FbP}yltleRbRy7nh3Qg-eEeK69rBO4*hnBeiK{uFu?9M1 nxi{z9=Q^x}^$jQWy^- Empezando copia ..."); + + for (int i = 0; i <= 200; i = i + 20) { + + //Invocamos al metodo + progressPercentage(i, 200); + + //Ralentizamos el output + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + } + + System.out.println("\n+ Se ha finalizado la copia correctamente"); + + } + + //Cerramos los lectores + in.close(); + out.close(); + + } + + /** + * Muestra el porcentaje del progreso [0/100%] + */ + private static void progressPercentage(int remain, int total) { + + //Si lo restante supera al total, lanzaremos excepcion + if (remain > total) + throw new IllegalArgumentException(); + + //Generamos los atributos in-class + int maxSize = 10, remaining = calcProgress(remain, total, maxSize); + char notDone = '-'; + String done = "■", bare = new String(new char[maxSize]).replace('\0', notDone) + "]", bareDone = "[", + bareRemain = bare.substring(remaining, bare.length());; + + for (int i = 0; i < remaining; i++) + bareDone += done; + + //Imprimimos el resultado + System.out.print("\r" + bareDone + bareRemain + " " + remaining * 10 + "%"); + + } + + /** + * Calculo del progreso + */ + private static int calcProgress(int remain, int total, int maxBareSize) { + return ((100 * remain) / total) / maxBareSize; + } + +}