O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Let's first create a method to read the fall of wickets data from the file:
        private Map<String, List<FallOfWicket>> getFallOfWickets() 
                throws IOException{
          Scanner reader = new Scanner(getClass()
                           .getModule()
                           .getResourceAsStream("com/packt/wickets")
          );
          Map<String, List<FallOfWicket>> data = new HashMap<>();
          while(reader.hasNext()){
            String line = reader.nextLine();
            String[] elements = line.split(",");
            String country = elements[0];
            if ( !data.containsKey(country)){
              data.put(country, new ArrayList<FallOfWicket>());
            }
            data.get(country).add(new FallOfWicket(elements));
          }
          return data;
        }
  1. A scatter chart is also an X-Y chart; we will use XYChart.Series to create data for the chart. Let's write a method to create an instance of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required