Estoy trabajando con objetos y guardandolos en un archivo binario y deseo ayuda con el metodo de buscar un paciente a traves de su numero de expediente o DNI el codigo de guardar es el sguiente:
 
private void btcGuardarActionPerformed(java.awt.event.ActionEve  nt evt) {                                           
        // TODO add your handling code here:
        Object nombreArchivo = archivo;
        System.out.println(nombreArchivo);
        try{
            ObjectOutputStream fileout = new ObjectOutputStream(new FileOutputStream((String) nombreArchivo));
            fileout.writeObject(txtNroExpediente.getText());
            fileout.writeObject(txtDni.getText());
            fileout.writeObject(txtApellidos.getText());
            fileout.writeObject(txtNombres.getText());
            fileout.writeObject(txtDireccion.getText());
            fileout.writeObject(txtTelefono.getText());
            fileout.writeObject(lblFoto.getIcon());
            JOptionPane.showMessageDialog(null, "Los datos del paciente se guardaron corecttamente...");
            if(fileout!=null){
                fileout.close();
            }
        }catch(IOException e){}
        desactivarTextFields();
        btcGuardar.setEnabled(false);
        btcNuevo.setEnabled(true);
        btcBuscar.setEnabled(false);
    }
 
el de buscar es el siguiente y solo me muestra el ultimo ingresado.
private void btcBuscarActionPerformed(java.awt.event.ActionEven  t evt) {                                          
        // TODO add your handling code here:
        Object nombreArchivo = archivo;
        try{
            try (ObjectInputStream filein = new ObjectInputStream(new FileInputStream((String) nombreArchivo))){
                Object expediente = filein.readObject();
                Object dni = filein.readObject();
                Object apellidos = filein.readObject();
                Object nombres = filein.readObject();
                Object direccion = filein.readObject();
                Object telefono = filein.readObject();
                Object foto = filein.readObject();
                txtNroExpediente.setText((String) expediente);
                txtDni.setText((String) dni);
                txtApellidos.setText((String) apellidos);
                txtNombres.setText((String) nombres);
                txtDireccion.setText((String) direccion);
                txtTelefono.setText((String) telefono);
                lblFoto.setIcon((Icon) foto);
                if(filein!=null){
                    filein.close();
                }
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(JDPacientes.class.getName()).log(  Level.SEVERE, null, ex);
            }
        }catch(IOException e){}   
    }
 
gracias de antemano. 
   
 



