ive been working on this for a while and have tried several alternatives and its getting late heh. I am having problems taking a radiobutton, and storing it as a string in a .csv file.
The main line i am interested in is the one underlined, every time i try to save it into a .csv file i get an error "null"try{ if(btn1.isSelected()) { gender = "Male"; } if(btn2.isSelected()) { gender = "Female"; } FileWriter writer = new FileWriter("Student.csv"); writer.write(lbl1 + ", " + txt1.getText()); writer.write('\n'); writer.write(lbl1 + ", "); writer.write('\n'); [B][U]writer.write(lbl3 + gender);[/U][/B] writer.write('\n'); writer.write(lbl2 + ", " + txt2.getText()); writer.close(); } catch (Exception e){ System.err.println("Error: " + e.getMessage()); }
this is the other way i tried.
String choice = group.getSelection().getActionCommand(); try{ FileWriter writer = new FileWriter("Student.csv"); writer.write(lbl1 + ", " + txt1.getText()); writer.write('\n'); [B][U]writer.write(lbl7 + ", " + choice);[/U][/B] writer.write('\n'); writer.write(lbl2 + ", " + txt2.getText()); writer.close(); } catch (Exception e){ System.err.println("Error: " + e.getMessage()); }
ignore all the other rubbish around it