Utils { public static String[] classpathStringToArray(String cp) { cp = cp.trim(); String[] entries = cp.split(":"); List<String> results = new ArrayList<>(); for (int i = 0; i < entries.length; i++) { String entry = entries[i]; if (i + 1 < entries.length) { String nextEntry = entries[i + 1]; if (entry.matches("[A-Za-z]") && nextEntry.charAt(0) == '\\') { results.add(entry + ":" + nextEntry); i++; continue; } } results.add(entry); } return results.toArray(new String[results.size()]); }  static List<URL> classpathStringToURLS(String cp); static List<File> classpathStringToFiles(String cp); static String[] classpathStringToArray(String cp); static void deleteRecursively(File directory);  }
@Test public void testClasspathStringWindowsDriveLetters() { String[] array = Utils.classpathStringToArray("C:\\foobar:D:\\baz"); assertEquals("C:\\foobar", array[0]); assertEquals("D:\\baz", array[1]); }