public void init(String fileName) throws IOException, PusherException
    {
        goalNumber = 0;
        goalCount = 0;
        int i = 0;
        int pos = -1;
        int boxNumber = 0;

        try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)))){
            String str = reader.readLine();
            if(!"map".equals(str))
            {
                throw new PusherException("wrong file format");
            }

            for(str = reader.readLine(); str != null; str = reader.readLine(), i++)
            {
                pos = str.indexOf('t');
                if(pos >= 0)
                {
                    posY = pos;
                    posX = i;
                }

                goalNumber += str.replaceAll("[^&]", "").length();
                boxNumber += str.replaceAll("[^*]", "").length();

                map[i] = str.replaceAll("[^x&]", ".").toCharArray();
                boxes[i] = str.replaceAll("[^*]", ".").toCharArray();
            }
            height = i;
            width = map[0].length;

            if(boxNumber != goalNumber)
            {
                throw new PusherException("should be the same number of boxes and goals");
            }
        }

        level = fileName;
    }