|
@ -10,12 +10,12 @@ import javax.swing.JProgressBar; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class MyCopy extends JFrame{ |
|
|
public class MyCopy extends JFrame{ |
|
|
private JLabel Porcentaje; |
|
|
|
|
|
|
|
|
private JLabel porcentaje; |
|
|
private JProgressBar barra; |
|
|
private JProgressBar barra; |
|
|
private String RutaIn, RutaOut; |
|
|
|
|
|
public MyCopy(String in, String out) throws IOException { |
|
|
|
|
|
RutaIn = in; |
|
|
|
|
|
RutaOut = out; |
|
|
|
|
|
|
|
|
private String rutaIn, rutaOut; |
|
|
|
|
|
public MyCopy(String in, String out) throws IOException, InterruptedException { |
|
|
|
|
|
rutaIn = in; |
|
|
|
|
|
rutaOut = out; |
|
|
Componentes(); |
|
|
Componentes(); |
|
|
Copiar(); |
|
|
Copiar(); |
|
|
|
|
|
|
|
@ -25,9 +25,9 @@ public class MyCopy extends JFrame{ |
|
|
barra = new JProgressBar(); |
|
|
barra = new JProgressBar(); |
|
|
barra.setBounds(125, 65, 150, 10); |
|
|
barra.setBounds(125, 65, 150, 10); |
|
|
add(barra); |
|
|
add(barra); |
|
|
Porcentaje = new JLabel(); |
|
|
|
|
|
Porcentaje.setBounds(190,-45,100,150); |
|
|
|
|
|
add(Porcentaje); |
|
|
|
|
|
|
|
|
porcentaje = new JLabel(); |
|
|
|
|
|
porcentaje.setBounds(190,-45,100,150); |
|
|
|
|
|
add(porcentaje); |
|
|
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
setSize(400,150); |
|
|
setSize(400,150); |
|
|
setLocationRelativeTo(null); |
|
|
setLocationRelativeTo(null); |
|
@ -37,9 +37,9 @@ public class MyCopy extends JFrame{ |
|
|
setTitle("Copiando"); |
|
|
setTitle("Copiando"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Copiar() throws IOException { |
|
|
|
|
|
File fich = new File(RutaOut); |
|
|
|
|
|
File fich_a_copiar = new File(RutaIn); |
|
|
|
|
|
|
|
|
public void Copiar() throws IOException, InterruptedException { |
|
|
|
|
|
File fich = new File(rutaOut); |
|
|
|
|
|
File fich_a_copiar = new File(rutaIn); |
|
|
if(fich_a_copiar.exists() == false) { |
|
|
if(fich_a_copiar.exists() == false) { |
|
|
fich_a_copiar.createNewFile(); |
|
|
fich_a_copiar.createNewFile(); |
|
|
} |
|
|
} |
|
@ -49,37 +49,30 @@ public class MyCopy extends JFrame{ |
|
|
DataOutputStream dout = new DataOutputStream(out); |
|
|
DataOutputStream dout = new DataOutputStream(out); |
|
|
String[] calculando = {"-", "\\", "|", "/"}; |
|
|
String[] calculando = {"-", "\\", "|", "/"}; |
|
|
int cal=0; |
|
|
int cal=0; |
|
|
int i=0; |
|
|
|
|
|
int c; |
|
|
int c; |
|
|
ArrayList bufferin = new ArrayList(); |
|
|
ArrayList bufferin = new ArrayList(); |
|
|
|
|
|
|
|
|
while((c = din.read() ) != -1 && bufferin.add(c)) { |
|
|
while((c = din.read() ) != -1 && bufferin.add(c)) { |
|
|
Porcentaje.setText(calculando[cal]); |
|
|
|
|
|
|
|
|
porcentaje.setText(calculando[cal]); |
|
|
|
|
|
porcentaje.update(porcentaje.getGraphics()); |
|
|
cal++; |
|
|
cal++; |
|
|
if (cal >= 4) |
|
|
if (cal >= 4) |
|
|
cal = 0; |
|
|
cal = 0; |
|
|
try { |
|
|
|
|
|
Thread.sleep(50); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
// TODO Auto-generated catch block |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Thread.sleep(40); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for(int j = 0; j<bufferin.size(); j++) { |
|
|
for(int j = 0; j<bufferin.size(); j++) { |
|
|
int porcentaje1 = (j*100)/bufferin.size(); |
|
|
int porcentaje1 = (j*100)/bufferin.size(); |
|
|
porcentaje1++; |
|
|
porcentaje1++; |
|
|
Porcentaje.setText(porcentaje1+"%"); |
|
|
|
|
|
|
|
|
porcentaje.setText(""); |
|
|
|
|
|
porcentaje.setText(porcentaje1+"%"); |
|
|
barra.setValue(porcentaje1); |
|
|
barra.setValue(porcentaje1); |
|
|
|
|
|
porcentaje.update(porcentaje.getGraphics()); |
|
|
|
|
|
barra.update(barra.getGraphics()); |
|
|
dout.write((int)bufferin.get(j)); |
|
|
dout.write((int)bufferin.get(j)); |
|
|
try { |
|
|
|
|
|
Thread.sleep(40); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
// TODO Auto-generated catch block |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Thread.sleep(20); |
|
|
} |
|
|
} |
|
|
Porcentaje.setText("Completado!"); |
|
|
|
|
|
|
|
|
porcentaje.setText("Completado!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|