#How do I display text in text area?

1 messages · Page 1 of 1 (latest)

desert rock
#
    public TextArea textArea;
    private Stage stage;
    private Scene scene;
    private Parent root;

    @FXML
    public void displayTeamsData() throws Exception {
        //Calling the NBA API for teams.
        URL urlTeams = new URL("https://www.balldontlie.io/api/v1/teams");
        Scanner JsonScan1 = new Scanner(urlTeams.openStream());

        //Using the data from the Json scans and putting them into a String called rawData.
        StringBuilder rawDataTeams = new StringBuilder();

        while (JsonScan1.hasNextLine()) {
            rawDataTeams.append(JsonScan1.nextLine());
        }

        //Creating a gson object
        Gson gson = new Gson();
        TeamsList teamsList = gson.fromJson(rawDataTeams.toString(), TeamsList.class);

        //Accessing team data from TeamsList object
        Teams[] teams = teamsList.getData();

        //Print details for all teams
        if (teams != null) {
            for (Teams team : teams) {
                System.out.println(team.toString());
            }
        }
    }

The way the api im calling is formatted is like this

TeamAtlanta Hawks
Team ID: 1
Abbreviation: ATL
City: Atlanta
Conference: East
Division: Southeast
Name: Hawks

I just want to display that in the text area how do I do that

median turtleBOT
# desert rock ``` public TextArea textArea; private Stage stage; private Scene sce...

Detected code, here are some useful tools:

Formatted code
public TextArea textArea;
private Stage stage;
private Scene scene;
private Parent root;
@FXML
public void displayTeamsData() throws Exception {
  //Calling the NBA API for teams.
  URL urlTeams = new URL("https://www.balldontlie.io/api/v1/teams");
  Scanner JsonScan1 = new Scanner(urlTeams.openStream());
  //Using the data from the Json scans and putting them into a String called rawData.
  StringBuilder rawDataTeams = new StringBuilder();
  while (JsonScan1.hasNextLine()) {
    rawDataTeams.append(JsonScan1.nextLine());
  }
  //Creating a gson object
  Gson gson = new Gson();
  TeamsList teamsList = gson.fromJson(rawDataTeams.toString(), TeamsList.class );
  //Accessing team data from TeamsList object
  Teams[] teams = teamsList.getData();
  //Print details for all teams
  if (teams != null ) {
    for (Teams team : teams) {
      System.out.println(team.toString());
    }
  }
}
#

<@&987246487241105418> please have a look, thanks.