ObjectOutputStream .writeObject
- by bigbluedragon
hey
i have some problems with this code... This is a JDialogForm in which I have jTextField and button. I want to save data from this Jtextfield when i click button to use it in another window but i don't know why it doesn't work. I always get Exception ek and the message i have put there.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String sciezka = jTextField1.getText();
if (sciezka.length() > 0)
{
Zmienne_pomocnicze zp = new Zmienne_pomocnicze();
zp.setPrzechowaj(sciezka);
try {
ObjectOutputStream oos = new ObjectOutputStream (new FileOutputStream("danebaza"));
oos.writeObject(zp);
oos.close();
} catch(Exception ek) {
JOptionPane.showMessageDialog(null, "Nie mozna pobrac nazwy_przedmiotu: " + ek);
}
}
this.setVisible(false);
}
where class Zmienne_pomocnicze looks like this
public class Zmienne_pomocnicze {
public String n;
public void setPrzechowaj (String neew){
n = neew;
} public String getPrzechowaj () {
return n;
}
}
i guess the problem is with oos.writeObject(zp); but i don't know why.