gt:         for(int time : myMap.keySet()) {
context: /** @author Ben Mueller, ben.mueller1998@enlitendfarmer.com
   *  This program will first tell the user if there are any
   *  values currently in use, and which file they are using
   *  for the database, and allow them to choose a file or add
   *  to it. If no file is selected, output to default.txt.
   */
  
  import java.util.*;
  import java.io.*;
  
  public class ListOrganizer {
  
      static String fileName = "default.txt";
  
      static boolean isRunning = true;
  
      static HashMap<Integer, String> songs = new HashMap<Integer, String>();
  
      public static void main( String [] args ) {
  
          try {
              runProgram();
          } catch (Exception e) {
              System.out.println("Error! " + e); //Should never happen, just here to make the compiler happy.
          }
      }
  
      public static void runProgram() throws IOException {
          System.out.println("Program Started! Do you want to use the default save file? (y/n):");
  
          Scanner input = new Scanner(System.in);
          String choice = input.nextLine();
  
          if(choice.trim().equalsIgnoreCase("y")) {
              getSongs(fileName, songs);
          } else if(choice.trim().equalsIgnoreCase("n")) {
              System.out.print("Please enter a filename: ");
              fileName = input.next();
              getSongs(fileName, songs);
          }
          while(isRunning) {
              System.out.println("\n\nThis program currently stores " + songs.size() + " unique songs.");
              System.out.println("These values are currently being read from " + fileName + ".");
              System.out.println("What would you like to do?\n"
                               + "1. List songs by title\n"
                               + "2. Show the shortest song\n"
                               + "3. Show the longest song\n"
                               + "4. Find the time of all songs\n"
                               + "5. Find the length of a specified song\n"
                               + "6. Exit Program\n"
                               + "Your choice?");
              switch(input.nextInt()) {
  
              case 1:
                  printValuesOrdered(songs);
                  break;
              case 2:
                  System.out.println("The shortest song is " + getShortestSong(songs));
                  break;
              case 3:
                  System.out.println("The longest song is " + getLongestSong(songs));
                  break;
              case 4:
                  System.out.println("The total length of all songs is " + getMusicTime(songs));
                  break;
              case 5:
                  System.out.println("Please enter a song name:");
                  input.nextLine();
                  System.out.println("Your song is " + getSongTime(input.nextLine(), songs) + " long.");
                  break;
              case 6:
                  isRunning = false;
                  break;
              }
          }
      }
  
      //Gets the songs/lengths from a file
      public static void getSongs(String fileName, HashMap<Integer, String> myMap) throws IOException {
          if(!fileExists(fileName))
              createFile(fileName);
          String names = "";
          Scanner fromFile = new Scanner(new File(fileName));
          while(fromFile.hasNextLine()) {
              names = "";
              String [] line = fromFile.nextLine().split("-");
              for(int i = 0; i < line.length - 1; i++) {
                  names = names + line[i] + "-";
                  if(i == line.length - 2)
                      names = names.substring(0, names.length() - 1);
              }
              myMap.put(Integer.parseInt(line[line.length - 1]), line[0]); //TODO: handle if the DOB is already used for someone else
          }
      }
  
      public static boolean fileExists(String fileName) throws IOException {
          File f = new File(fileName);
          boolean result = f.exists();
          return result;
      }
  
      public static void createFile(String fileName) throws IOException {
          File f = new File(fileName);
          f.createNewFile();
      }
  
      //This one returns all values, organized by time
      public static void printValuesOrdered(HashMap<Integer, String> myMap) {
          for(int i = 0; i < 40; i++)
              System.out.print("=");
  
          for(int time : myMap.keySet())
              System.out.printf("\n|%-23s|%-15s|", myMap.get(time), getHMS(time));
  
          System.out.println();
          for(int i = 0; i < 40; i++)
              System.out.print("=");
      }
  
      public static int getSeconds(String hms) { //hms = hours minutes seconds
  
          String[] hmsString = hms.split(":");
          int[] hmsArray = new int[hmsString.length];
          for(int i = 0; i < hmsArray.length; i++)
              hmsArray[i] = Integer.parseInt(hmsString[i]);
  
          if(hmsArray.length == 3) { //If the audio recording is more than an hour long...
              return ((hmsArray[0] * 60 * 60) + (hmsArray[1] * 60) + hmsArray[2]);
          } else if(hmsArray.length == 2) {
              return ((hmsArray[0] * 60) + hmsArray[1]);
          } else if(hmsArray.length == 1) {
              return hmsArray[0];
          } else {
              return -1; //Bad input
          }
      }
  
      public static String getHMS(int seconds) {
          int minutes = 0;
          int hours = 0;
          int leftoverSeconds = 0;
          //Split into minutes and seconds first
          if((seconds / 60) > 0) { //if has more than a minute
              minutes = seconds / 60;
              leftoverSeconds = seconds % 60;
  
              if((minutes / 60) > 0) { //if has more than an hour
                  hours = minutes / 60;
                  minutes = minutes % 60;
              }
          }
          if(hours > 0) {
              return (hours + ":" + minutes + ":" + leftoverSeconds);
          } else if (minutes > 0) {
              return (minutes + ":" + leftoverSeconds);
          } else {
              return leftoverSeconds + "";
          }
      }
  
      public static String getShortestSong(HashMap<Integer, String> myMap) {
          boolean firstTime = true;
          int lowValue = 0;
          for(int time : myMap.keySet()) {
              if(firstTime) {
                  lowValue = time;
                  firstTime = false;
              } else if(lowValue > time)
                  lowValue = time;
          }
          return myMap.get(lowValue);
      }
  
      public static String getLongestSong(HashMap<Integer, String> myMap) {
          boolean firstTime = true;
          int highValue = 0;
          for(int time : myMap.keySet()) {
              if(firstTime) {
                  highValue = time;
                  firstTime = false;
              } else if(highValue < time)
                  highValue = time;
          }
          return myMap.get(highValue);
      }
  
      public static String getMusicTime(HashMap<Integer, String> myMap) {
          boolean firstTime = true;
          int timeValue = 0;
          for(int time : myMap.keySet()) {
              if(firstTime) {
                  timeValue = time;
                  firstTime = false;
              } else
                  timeValue += time;
          }
          return getHMS(timeValue);
      }
  
      public static String getSongTime(String query, HashMap<Integer, String> myMap) {
  