|
|
@ -1,64 +1,87 @@ |
|
|
|
package jorpelu.com; |
|
|
|
|
|
|
|
import java.awt.GridLayout; |
|
|
|
import java.awt.PopupMenu; |
|
|
|
import java.io.*; |
|
|
|
import java.io.File; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JProgressBar; |
|
|
|
import javax.swing.JTextField; |
|
|
|
|
|
|
|
public class MyCopy { |
|
|
|
Ventana ventana; |
|
|
|
|
|
|
|
public class MyCopy extends JFrame{ |
|
|
|
|
|
|
|
public static void main(String[] args) throws FileNotFoundException, IOException { |
|
|
|
File fich = new File(".\\Salida.dat"); |
|
|
|
File fich_a_copiar = new File("textp.dat"); |
|
|
|
public MyCopy(String RutaIn, String RutaOut) throws IOException { |
|
|
|
|
|
|
|
/* |
|
|
|
* Componentes de Ventana de caarga |
|
|
|
*/ |
|
|
|
JLabel Porcentaje = new JLabel(); |
|
|
|
Porcentaje.setBounds(100,0,20,200); |
|
|
|
add(Porcentaje); |
|
|
|
JProgressBar barra = new JProgressBar(); |
|
|
|
barra.setBounds(100, 20, 150, 10); |
|
|
|
add(barra); |
|
|
|
/* |
|
|
|
* Variables para copiar |
|
|
|
*/ |
|
|
|
File fich = new File(RutaOut); |
|
|
|
File fich_a_copiar = new File(RutaIn); |
|
|
|
if(fich_a_copiar.exists() == false) { |
|
|
|
fich_a_copiar.createNewFile(); |
|
|
|
} |
|
|
|
String[] calculando = {"-", "\\", "|", "/"}; |
|
|
|
|
|
|
|
FileInputStream in = new FileInputStream(fich_a_copiar); |
|
|
|
DataInputStream din = new DataInputStream(in); |
|
|
|
FileOutputStream out = new FileOutputStream(fich); |
|
|
|
DataOutputStream dout = new DataOutputStream(out); |
|
|
|
String[] calculando = {"-", "\\", "|", "/"}; |
|
|
|
int cal=0; |
|
|
|
int i=0; |
|
|
|
int c; |
|
|
|
ArrayList bufferin = new ArrayList(); |
|
|
|
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
setSize(400,100); |
|
|
|
setLocationRelativeTo(null); |
|
|
|
setLayout(null); |
|
|
|
setResizable(false); |
|
|
|
setVisible(true); |
|
|
|
setTitle("Copiando"); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
while((c = din.read() ) != -1 && bufferin.add(c)) { |
|
|
|
System.out.println(calculando[cal]); |
|
|
|
Porcentaje.setText(calculando[cal]); |
|
|
|
cal++; |
|
|
|
if (cal >= 4) |
|
|
|
cal = 0; |
|
|
|
|
|
|
|
try { |
|
|
|
Thread.sleep(100); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
Thread.sleep(100); |
|
|
|
} |
|
|
|
|
|
|
|
for(int j = 0; j<bufferin.size(); j++) { |
|
|
|
int porcentaje = (j*100)/bufferin.size(); |
|
|
|
System.out.println(porcentaje+1 + "%"); |
|
|
|
for(int q = 0; q<=porcentaje+1; q++) { |
|
|
|
System.out.print("@"); |
|
|
|
} |
|
|
|
for(int q = porcentaje+1; q<100; q++) { |
|
|
|
System.out.print("_"); |
|
|
|
} |
|
|
|
System.out.println(""); |
|
|
|
int porcentaje1 = (j*100)/bufferin.size(); |
|
|
|
porcentaje1++; |
|
|
|
Porcentaje.setText(porcentaje1+"%"); |
|
|
|
barra.setValue(porcentaje1); |
|
|
|
// for(int q = 0; q<=porcentaje1+1; q++) { |
|
|
|
// System.out.print("@"); |
|
|
|
// } |
|
|
|
// for(int q = porcentaje1+1; q<100; q++) { |
|
|
|
// System.out.print("_"); |
|
|
|
// } |
|
|
|
dout.write((int)bufferin.get(j)); |
|
|
|
try { |
|
|
|
Thread.sleep(40); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
Thread.sleep(40); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (InterruptedException | IOException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|