@Test public void testSplitURLSlashAtStartEnd() { final String url = "/www.eurohandball.com/"; final char delim = '/'; List<String> parts = Utils.split(url, delim); Assert.assertEquals(Arrays.asList(StringUtils.split(url, delim)), parts); }
public static List<String> split(String strToSplit, char delimiter) { List<String> parts = new ArrayList<>(); int foundPosition; int startIndex = 0; String part; while ((foundPosition = strToSplit.indexOf(delimiter, startIndex)) > -1) { part = strToSplit.substring(startIndex, foundPosition); if(part.length() > 0) { parts.add(part); } startIndex = foundPosition + 1; } if(startIndex < strToSplit.length()) { parts.add(strToSplit.substring(startIndex)); } return parts; }
Utils { public static List<String> split(String strToSplit, char delimiter) { List<String> parts = new ArrayList<>(); int foundPosition; int startIndex = 0; String part; while ((foundPosition = strToSplit.indexOf(delimiter, startIndex)) > -1) { part = strToSplit.substring(startIndex, foundPosition); if(part.length() > 0) { parts.add(part); } startIndex = foundPosition + 1; } if(startIndex < strToSplit.length()) { parts.add(strToSplit.substring(startIndex)); } return parts; } }
Utils { public static List<String> split(String strToSplit, char delimiter) { List<String> parts = new ArrayList<>(); int foundPosition; int startIndex = 0; String part; while ((foundPosition = strToSplit.indexOf(delimiter, startIndex)) > -1) { part = strToSplit.substring(startIndex, foundPosition); if(part.length() > 0) { parts.add(part); } startIndex = foundPosition + 1; } if(startIndex < strToSplit.length()) { parts.add(strToSplit.substring(startIndex)); } return parts; }  }
Utils { public static List<String> split(String strToSplit, char delimiter) { List<String> parts = new ArrayList<>(); int foundPosition; int startIndex = 0; String part; while ((foundPosition = strToSplit.indexOf(delimiter, startIndex)) > -1) { part = strToSplit.substring(startIndex, foundPosition); if(part.length() > 0) { parts.add(part); } startIndex = foundPosition + 1; } if(startIndex < strToSplit.length()) { parts.add(strToSplit.substring(startIndex)); } return parts; }  static List<String> split(String strToSplit, char delimiter); static Set<String> splitNoDuplicates(String strToSplit, char delimiter); static long getUncompressedFileSize(String filename); static void downloadFile(String url, String file); static void waitForEquality(Object value1, Object value2, int seconds); static void mergeCountMaps(Map<K, Integer> base, Map<K, Integer> other); static void main(String[] args); static ExecutorService createFixedThreadPool(Integer numOfThreads); static int getStringSize(String text); static void objectToJsonFile(String filename, Object object); static void objectToFile(String filename, Object object, boolean compress); static void objectToFile(String filename, Object object, boolean compress, boolean java); static T objectFromFile(String filename, Class<T> classOfT, boolean compressed); @SuppressWarnings("unchecked") static T objectFromFile(String filename, Class<T> classOfT, boolean compressed, boolean java); static String compressFile(String inFile); static String unCompressFile(String filename); static void logCpuStats(); static long getMemoryUsage(); static double getMemoryUsageInGB(); static void logMemoryUsageInGB(); }
Utils { public static List<String> split(String strToSplit, char delimiter) { List<String> parts = new ArrayList<>(); int foundPosition; int startIndex = 0; String part; while ((foundPosition = strToSplit.indexOf(delimiter, startIndex)) > -1) { part = strToSplit.substring(startIndex, foundPosition); if(part.length() > 0) { parts.add(part); } startIndex = foundPosition + 1; } if(startIndex < strToSplit.length()) { parts.add(strToSplit.substring(startIndex)); } return parts; }  static List<String> split(String strToSplit, char delimiter); static Set<String> splitNoDuplicates(String strToSplit, char delimiter); static long getUncompressedFileSize(String filename); static void downloadFile(String url, String file); static void waitForEquality(Object value1, Object value2, int seconds); static void mergeCountMaps(Map<K, Integer> base, Map<K, Integer> other); static void main(String[] args); static ExecutorService createFixedThreadPool(Integer numOfThreads); static int getStringSize(String text); static void objectToJsonFile(String filename, Object object); static void objectToFile(String filename, Object object, boolean compress); static void objectToFile(String filename, Object object, boolean compress, boolean java); static T objectFromFile(String filename, Class<T> classOfT, boolean compressed); @SuppressWarnings("unchecked") static T objectFromFile(String filename, Class<T> classOfT, boolean compressed, boolean java); static String compressFile(String inFile); static String unCompressFile(String filename); static void logCpuStats(); static long getMemoryUsage(); static double getMemoryUsageInGB(); static void logMemoryUsageInGB(); static final String PATH_SEPARATOR; static final String TEMP_FOLDER; static final byte [] SEPARATOR; static final int BUFFER_SIZE; static Gson GSON; static final KryoPool POOL; }