#JavaFX question
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wide musk! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
at org.json@20240303/org.json.JSONObject.get(JSONObject.java:596)
at org.json@20240303/org.json.JSONObject.getJSONObject(JSONObject.java:806)
at com.example.currencytranslator/com.example.currencytranslator.ControllerAbstractions.doWork(ControllerAbstractions.java:41)
at com.example.currencytranslator/com.example.currencytranslator.Mainscreen.doWork(Mainscreen.java:19)
at com.example.currencytranslator/com.example.currencytranslator.Mainscreen$1.handle(Mainscreen.java:56)
at com.example.currencytranslator/com.example.currencytranslator.Mainscreen$1.handle(Mainscreen.java:46)
I get this
public double doWork(String endpoint, int value, String translated) {
try {
URL url = new URL(endpoint);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = reader.readLine()) != null) {
response.append(inputLine);
}
reader.close();
JSONObject jsonResponse = new JSONObject(response.toString());
rate = jsonResponse.getJSONObject("rates").getDouble(translated); // TRY kuru
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(rate.toString());
return (value * rate);
}```
Code line is this
this has nothing to do with javaFX
Sorry, wrong containment.