Browse Source

añado MyCopy y la empiezo a modificar

master
vigliom 2 years ago
parent
commit
84645971e0
10 changed files with 132 additions and 0 deletions
  1. +6
    -0
      .classpath
  2. +17
    -0
      .project
  3. +0
    -0
      Salida.dat
  4. BIN
      bin/jorpelu/com/MyCopy.class
  5. BIN
      bin/jorpelu/com/Ventana.class
  6. BIN
      bin/module-info.class
  7. +70
    -0
      src/jorpelu/com/MyCopy.java
  8. +38
    -0
      src/jorpelu/com/Ventana.java
  9. +1
    -0
      src/module-info.java
  10. +0
    -0
      textp.dat

+ 6
- 0
.classpath View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 17
- 0
.project View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MiVentana</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

+ 0
- 0
Salida.dat View File


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


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


BIN
bin/module-info.class View File


+ 70
- 0
src/jorpelu/com/MyCopy.java View File

@ -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();
}
}
}

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

@ -0,0 +1,38 @@
package jorpelu.com;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Ventana extends JFrame{
private JLabel titulo, porcentaje, Barra;
private JTextField ruta;
public static void main(String[] args) {
new Ventana();
}
public Ventana() {
Componentes();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,600);
setVisible(true);
setTitle("**Copiador de Archivos**");
}
public void Componentes() {
titulo = new JLabel();
titulo.setBounds(getBounds());
titulo.setText("Escriba la ruta de un archivo que quiera copiar: ");
add(titulo);
ruta = new JTextField();
ruta.setBounds(getBounds());
}
}

+ 1
- 0
src/module-info.java View File

@ -6,4 +6,5 @@
* *
*/ */
module MiVentana { module MiVentana {
requires java.desktop;
} }

+ 0
- 0
textp.dat View File


Loading…
Cancel
Save