Browse Source

mas o menos va, necesita pulir

master
vigliom 2 years ago
parent
commit
9abd25d027
8 changed files with 76 additions and 39 deletions
  1. +3
    -0
      README.md
  2. BIN
      bin/jorpelu/com/MyCopy.class
  3. BIN
      bin/jorpelu/com/Ventana.class
  4. BIN
      bin/jorpelu/com/main.class
  5. +54
    -31
      src/jorpelu/com/MyCopy.java
  6. +0
    -8
      src/jorpelu/com/Ventana.java
  7. +16
    -0
      src/jorpelu/com/main.java
  8. +3
    -0
      textp.dat

+ 3
- 0
README.md View File

@ -1,2 +1,5 @@
# MiVentana # MiVentana
~~~
~~~

BIN
bin/jorpelu/com/MyCopy.class View File


BIN
bin/jorpelu/com/Ventana.class View File


BIN
bin/jorpelu/com/main.class View File


+ 54
- 31
src/jorpelu/com/MyCopy.java View File

@ -1,64 +1,87 @@
package jorpelu.com; package jorpelu.com;
import java.awt.GridLayout;
import java.awt.PopupMenu;
import java.io.*; import java.io.*;
import java.io.File;
import java.util.ArrayList; 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) { if(fich_a_copiar.exists() == false) {
fich_a_copiar.createNewFile(); fich_a_copiar.createNewFile();
} }
String[] calculando = {"-", "\\", "|", "/"};
FileInputStream in = new FileInputStream(fich_a_copiar); FileInputStream in = new FileInputStream(fich_a_copiar);
DataInputStream din = new DataInputStream(in); DataInputStream din = new DataInputStream(in);
FileOutputStream out = new FileOutputStream(fich); FileOutputStream out = new FileOutputStream(fich);
DataOutputStream dout = new DataOutputStream(out); DataOutputStream dout = new DataOutputStream(out);
String[] calculando = {"-", "\\", "|", "/"};
int cal=0; int cal=0;
int i=0; int i=0;
int c; int c;
ArrayList bufferin = new ArrayList(); 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)) { while((c = din.read() ) != -1 && bufferin.add(c)) {
System.out.println(calculando[cal]);
Porcentaje.setText(calculando[cal]);
cal++; cal++;
if (cal >= 4) if (cal >= 4)
cal = 0; 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++) { 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)); 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 // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}
} }
} }

+ 0
- 8
src/jorpelu/com/Ventana.java View File

@ -1,11 +1,3 @@
package jorpelu.com; package jorpelu.com;
import javax.swing.*;
public class Ventana extends JFrame{
private JLabel titulo, porcentaje, Barra;
private JTextField ruta;
}

+ 16
- 0
src/jorpelu/com/main.java View File

@ -0,0 +1,16 @@
package jorpelu.com;
import java.io.IOException;
public class main {
public static void main(String[] args) {
try {
MyCopy mc = new MyCopy("textp.dat", "Salida.dat");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

+ 3
- 0
textp.dat View File

@ -0,0 +1,3 @@
Esto es una prueba de la incorporacion de My copy a el programa,
Ya hace lo basico, pero voy a intentar organizar mejor las funciones y crear una pantalla
principal

Loading…
Cancel
Save