Задачу решил другим способом, этот код не проходил проверку на этапе проверки Integer, хотя всевозможные тесты код проходил. Это уже чисто дело интереса, может у кого-то есть мысли?
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;


public class Solution {
    public static void main(String[] args) {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)))
        {
            String key;
            while (!(key = reader.readLine()).equals("exit")) {
                try {
                    if (key.indexOf(".") != - 1) {
                        print(Double.valueOf(key));
                    } else if (Short.valueOf(key) > 0 && Short.valueOf(key) < 128) {
                        print(Short.valueOf(key));
                    } else if (Integer.parseInt(key) <= 0 || Integer.parseInt(key) >= 128) {
                        print(Integer.valueOf(key));
                    }
                } catch(Exception error) {
                    print(String.valueOf(key));
                    continue;
                }
            }
        } catch(IOException error) {
            error.printStackTrace();
        }
    }


    public static void print(Double value) {
        System.out.println("Это тип Double, значение " + value);
    }

    public static void print(String value) {
        System.out.println("Это тип String, значение " + value);
    }

    public static void print(short value) {
        System.out.println("Это тип short, значение " + value);
    }

    public static void print(Integer value) {
        System.out.println("Это тип Integer, значение " + value);
    }
}