Advertisement
Guest User

Untitled

a guest
May 19th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement