Save JSON obj via Jfilechooser
I have my textfields which contains numbers, and i collected that numbers and place them into my json object.
Code :
JSONObject obj = new JSONObject();
String prvi = textField.getText();
int prvi1 = Integer.parseInt(prvi);
String drugi = textField_1.getText();
int drugi1 = Integer.parseInt(drugi);
obj.put("lambda", new Integer (prvi1));
obj.put("mttr", new Integer(drugi1));
i can use filewriter to save but it has only default folder.
Code :
try {
FileWriter file = new FileWriter("c:\\test.json");
file.write(obj.toJSONString());
file.flush();
file.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.print(obj);
}
i have to save that object via Jfile chooser i suppose
Code :
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showSaveDialog(chooser);
if(returnVal == JFileChooser.APPROVE_OPTION) {
.....
}
I have no clue how to make my chooser to use that object and save it.
Little help please