Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean splitChecker(String line, char delimiter, String compareLine) {
- boolean allValid = true;
- int count = 1;
- char a[] = line.toCharArray();
- for (char c : a) {
- if (c == delimiter) {
- count++;
- }
- }
- CharSequence[] lineSequence = new CharSequence[count];
- CharSequence[] compareLineSequence = new CharSequence[count];
- int nWord = 0, lineIterator = 0, compareLineIterator = 0;
- int substringLineIndex = line.indexOf(delimiter, 0); // first substring
- int substringCompareIndex = compareLine.indexOf(delimiter, 0); // first substring
- while (substringLineIndex >= 0) {
- lineSequence[nWord] = line.substring(lineIterator, substringLineIndex);
- compareLineSequence[nWord] = compareLine.substring(compareLineIterator, substringCompareIndex);
- if(!lineSequence[nWord].equals(compareLineSequence[nWord])){
- return false;
- }
- System.out.println(lineSequence[nWord]+" == "+compareLineSequence[nWord]);
- nWord++;
- lineIterator = substringLineIndex + 1;
- compareLineIterator = substringCompareIndex + 1;
- substringLineIndex = line.indexOf(delimiter, lineIterator); // rest of substrings
- substringCompareIndex = compareLine.indexOf(delimiter, compareLineIterator);
- }
- lineSequence[nWord++] = line.substring(lineIterator); // last substring
- String[] result = new String[nWord];
- System.arraycopy(lineSequence, 0, result, 0, nWord);
- return allValid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement