The code with abbreviations, then the essence)
public class Main { public static void main(String[] args) throws FileNotFoundException, SQLException { Map<Integer, String> mapTrackFile = new HashMap<Integer, String>(); while (sc.hasNextLine()){ next = sc.nextLine(); if(next.contains(ABBREVIATYRA)){ mapTrackFile = Main.recordDataTrackOrMap(sc, next); } else if(next.contains(STARTS_OF_FRAGMENT)){ db.processString (koltrack, mapTrackFile, mapBD, count, sc); } } static Map recordDataTrackOrMap(Scanner sc, String next) { Map<Integer, String> mapTrackFile = new HashMap<Integer, String>(); //тут нахождение нужных параметров mapTrackFile.put(number, abbreviatura.trim()); return mapTrackFile; } MapTrack is taken from a file, it turns out that only the last key pair is recorded - the value, the keys are different 100%, that is, no rewriting takes place. What do I not understand so? Tell me please