SHARE
TWEET

Untitled

a guest May 19th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static boolean splitChecker(String line, char delimiter, String compareLine) {
  2.         boolean allValid = true;
  3.         int count = 1;
  4.         char a[] = line.toCharArray();
  5.         for (char c : a) {
  6.             if (c == delimiter) {
  7.                 count++;
  8.             }
  9.         }
  10.         CharSequence[] lineSequence = new CharSequence[count];
  11.         CharSequence[] compareLineSequence = new CharSequence[count];
  12.         int nWord = 0, lineIterator = 0, compareLineIterator = 0;
  13.         int substringLineIndex = line.indexOf(delimiter, 0); // first substring
  14.         int substringCompareIndex = compareLine.indexOf(delimiter, 0); // first substring
  15.         while (substringLineIndex >= 0) {
  16.             lineSequence[nWord] = line.substring(lineIterator, substringLineIndex);
  17.             compareLineSequence[nWord] = compareLine.substring(compareLineIterator, substringCompareIndex);
  18.             if(!lineSequence[nWord].equals(compareLineSequence[nWord])){
  19.                 return false;
  20.             }
  21.             System.out.println(lineSequence[nWord]+" == "+compareLineSequence[nWord]);
  22.             nWord++;
  23.             lineIterator = substringLineIndex + 1;
  24.             compareLineIterator = substringCompareIndex + 1;
  25.             substringLineIndex = line.indexOf(delimiter, lineIterator); // rest of substrings
  26.             substringCompareIndex = compareLine.indexOf(delimiter, compareLineIterator);
  27.  
  28.         }
  29.         lineSequence[nWord++] = line.substring(lineIterator); // last substring
  30.         String[] result = new String[nWord];
  31.         System.arraycopy(lineSequence, 0, result, 0, nWord);
  32.         return allValid;
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top