Hola, vereis tengo un Jlist creado en un JDialog y le paso objetos de la clase Clientes, posteriormente al cerra la ventana mando esos datos insertados a un fichero "Clientes.dat" pero al intentar cargarlos me sale el error invalid type code ac, estoy arto de probar cosas y cosas y no me funciona nadaa porfavor ayudenmeeee , siento si el código no esta muy limpio
public class Clientes implements Serializable{
String dni;
String nombre;
Boolean socio; //CHECK BOX
String ciudad; //COMBO BOX
int edad; //Spinner
public Clientes() {
}
public Clientes(String dni, String nombre, Boolean socio, String ciudad, int edad) {
this.dni = dni;
this.nombre = nombre;
this.socio = socio;
this.ciudad = ciudad;
this.edad = edad;
}
public String getDni() {
return dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Boolean getSocio() {
return socio;
}
public void setSocio(Boolean socio) {
this.socio = socio;
}
public String getCiudad() {
return ciudad;
}
public void setCiudad(String ciudad) {
this.ciudad = ciudad;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
@Override
public String toString() {
String a = "";
if (socio == true) {
a = "Si";
}
else{
a = "No";
}
return "Clientes( dni: "+dni+", nombre: "+nombre+", "
+ "socio: "+a+", ciudad: "+ciudad+", edad: "+edad+")";
}
}
void cargarLista(DefaultListModel m) {
ObjectInputStream file = null;
try {
file = new ObjectInputStream(new FileInputStream("Clientes.dat"));
} catch (IOException io) {
System.out.println(io.getMessage());
}
try {
do{
m.addElement(file.readObject());
}while(true);
} catch (EOFException eofe) {
System.out.println("Fin del fichero");
} catch (IOException | ClassNotFoundException ioe) {
System.out.println(ioe.getMessage());
}finally{
if (file != null) {
try {
file.close();
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}
public void enviarDatosListaClientes(DefaultListModel m) {
Clientes[] listaClientes = new Clientes[modelo.size()];
ObjectOutputStream obj = null;
for (int i = 0; i < listaClientes.length; i++) {
listaClientes = modelo.getElementAt(i);
}
try {
FileOutputStream f = new FileOutputStream("Clientes.dat", true);
obj = new ObjectOutputStream(f);
for (int i = 0; i < listaClientes.length; i++) {
// f.write(listaClientes.toString());
obj.writeObject(i + "\n");
}
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
}finally{
if (obj != null) {
try {
obj.reset();
obj.close();
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}
public class Clientes implements Serializable{
String dni;
String nombre;
Boolean socio; //CHECK BOX
String ciudad; //COMBO BOX
int edad; //Spinner
public Clientes() {
}
public Clientes(String dni, String nombre, Boolean socio, String ciudad, int edad) {
this.dni = dni;
this.nombre = nombre;
this.socio = socio;
this.ciudad = ciudad;
this.edad = edad;
}
public String getDni() {
return dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Boolean getSocio() {
return socio;
}
public void setSocio(Boolean socio) {
this.socio = socio;
}
public String getCiudad() {
return ciudad;
}
public void setCiudad(String ciudad) {
this.ciudad = ciudad;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
@Override
public String toString() {
String a = "";
if (socio == true) {
a = "Si";
}
else{
a = "No";
}
return "Clientes( dni: "+dni+", nombre: "+nombre+", "
+ "socio: "+a+", ciudad: "+ciudad+", edad: "+edad+")";
}
}
void cargarLista(DefaultListModel m) {
ObjectInputStream file = null;
try {
file = new ObjectInputStream(new FileInputStream("Clientes.dat"));
} catch (IOException io) {
System.out.println(io.getMessage());
}
try {
do{
m.addElement(file.readObject());
}while(true);
} catch (EOFException eofe) {
System.out.println("Fin del fichero");
} catch (IOException | ClassNotFoundException ioe) {
System.out.println(ioe.getMessage());
}finally{
if (file != null) {
try {
file.close();
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}
public void enviarDatosListaClientes(DefaultListModel m) {
Clientes[] listaClientes = new Clientes[modelo.size()];
ObjectOutputStream obj = null;
for (int i = 0; i < listaClientes.length; i++) {
listaClientes = modelo.getElementAt(i);
}
try {
FileOutputStream f = new FileOutputStream("Clientes.dat", true);
obj = new ObjectOutputStream(f);
for (int i = 0; i < listaClientes.length; i++) {
// f.write(listaClientes.toString());
obj.writeObject(i + "\n");
}
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
}finally{
if (obj != null) {
try {
obj.reset();
obj.close();
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}