Utils { public static float toFloat(String num, float defaultValue) { if (num != null && !num.contains(" ")) { try (Scanner scanner = new Scanner(num)) { if (scanner.hasNextFloat()) { return Float.parseFloat(num); } } } return defaultValue; } private  Utils(); static String readFile(File file, String charsetName); static String readStream(InputStream is, String charsetName); static void delete(File file); static int toInt(String num, int defaultValue); static int toIntHex(String num, int defaultValue); static long toLong(String num, long defaultValue); static long toLong(Long num, long defaultValue); static float toFloat(String num, float defaultValue); static String getJspEncoding(InputStream is); static void sendFile(HttpServletRequest request, HttpServletResponse response, File file); static Thread getThreadByName(String name); static String highlightStream(String name, InputStream input, String rendererName,
      String encoding); static void sendCompressedFile(HttpServletResponse response, File file); static List<String> getNamesForLocale(String baseName, Locale locale); static boolean isThreadingEnabled();  }
@Disabled @Test public void toFloatTest() { Assertions.assertEquals(5.0f, Utils.toFloat("garbage", 5.0f), 0.0); Assertions.assertEquals(3.0f, Utils.toFloat("3", 5.0f), 0.0); Assertions.assertEquals(5.0f, Utils.toFloat("3 3", 5.0f), 0.0); Assertions.assertEquals(5.0f, Utils.toFloat((String) null, 5.0f), 0.0); }