This repository contains a half-hour lesson in coding with my son. He does video game livestreaming and made a tool in Scratch that would pick a random Super Mario Galaxy level for him to play. After exploring his approach together, I showed him how it might be done in Java.
In a nutshell, this works by using the Scanner class to read a file from disk. The file is organized as a hierarchy of Galaxies, Stars, and Worlds. The file is read, parsed into objects and then a random level is picked.