Professional Documents
Culture Documents
Examen Programacion Aplicada Ejercicio 1
Examen Programacion Aplicada Ejercicio 1
public Fichero() {
initComponents();
generarFichero();
@SuppressWarnings("unchecked")
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Fichero 1:");
jLabel2.setText("Fichero 2:");
jLabel3.setText("Fichero salida:");
jFileChooser2.addActionListener(new java.awt.event.ActionListener() {
jFileChooser2ActionPerformed(evt);
});
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel1))
.addContainerGap(639, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)))
.addContainerGap(275, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
String[] ficheroUno;
String[] ficheroDos;
String[] ficheroFinal;
ficheroUno = chooser1.getSelectedFile();
ficheroDos = chooser2.getSelectedFile();
ficheroFinal = choose3.getCurrentDirectory();
public static void copiarFichero (String[] ficheroUno, String[] ficheroDos, String ficheroFinal) {
try {
int contador = 0;
int contador2 = 0;
FileOutputStream fileOutput = new FileOutputStream (ficheroFinal, true);
int leidos = 0;
int acumulado = 0;
int acumulado1 = 0;
int leidos2 = 0;
int acumulado3 = 0;
leidos = bufferedInput.read(array);
bufferedOutput.write(array, 0,leidos);
leidos=bufferedInput.read(array);
contador = contador + 1;
acumulado1 = acumulado;
bufferedOutput.flush();
bufferedInput.close();
}
while ( contador < ficheroDos.length ) {
leidos2 = bufferedInput.read(array);
bufferedOutput.write(array, 0,leidos);
leidos=bufferedInput.read(array);
contador2 = contador2 + 1;
acumulado3 = acumulado3;
bufferedOutput.flush();
bufferedInput.close();
bufferedOutput.close();
catch (Exception e)
e.printStackTrace();
}
private void jFileChooser2ActionPerformed(java.awt.event.ActionEvent evt) {