|
|
@ -0,0 +1,70 @@ |
|
|
|
package jorpelu.com; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
|
|
|
|
public class MyCopy { |
|
|
|
static Scanner sc = new Scanner(System.in); |
|
|
|
public MyCopy(){ |
|
|
|
|
|
|
|
String ficheroString = sc.next(); |
|
|
|
File fich = new File(".\\Salida.dat"); |
|
|
|
File fich_a_copiar = new File(ficheroString); |
|
|
|
if(fich_a_copiar.exists() == false) { |
|
|
|
try { |
|
|
|
fich_a_copiar.createNewFile(); |
|
|
|
} catch (IOException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
String[] calculando = {"-", "\\", "|", "/"}; |
|
|
|
|
|
|
|
FileInputStream in; |
|
|
|
try { |
|
|
|
in = new FileInputStream(fich_a_copiar); |
|
|
|
|
|
|
|
DataInputStream din = new DataInputStream(in); |
|
|
|
FileOutputStream out = new FileOutputStream(fich); |
|
|
|
DataOutputStream dout = new DataOutputStream(out); |
|
|
|
|
|
|
|
int cal=0; |
|
|
|
int i=0; |
|
|
|
int c; |
|
|
|
ArrayList bufferin = new ArrayList(); |
|
|
|
|
|
|
|
while((c =din.read()) != -1 && bufferin.add(c)) { |
|
|
|
System.out.println(calculando[cal]); |
|
|
|
cal++; |
|
|
|
if (cal >= 4) |
|
|
|
cal = 0; |
|
|
|
} |
|
|
|
|
|
|
|
for(int j = 0; j<bufferin.size(); j++) { |
|
|
|
|
|
|
|
int porcentaje = (j*100)/bufferin.size(); |
|
|
|
System.out.println(porcentaje + "%"); |
|
|
|
for(int q = 0; q<porcentaje; q++) { |
|
|
|
System.out.print("@"); |
|
|
|
} |
|
|
|
for(int q = porcentaje; q<100; q++) { |
|
|
|
System.out.print("_"); |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println(""); |
|
|
|
|
|
|
|
|
|
|
|
dout.write((int) bufferin.get(j)); |
|
|
|
} |
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (IOException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|