code: private static String[] split( String s ) {
          ArrayList list = new ArrayList();
  
          int lasti = 0;
          int i = s.indexOf("%");
          if (i == -1) {
              return new String[]{s};
          }
          if (i > 0) {
              list.add("+" + s.substring(0, i));
              lasti = i;
              i++;
              i = s.indexOf("%", i);
          } else if (i == 0) {
              i = s.indexOf("%", i + 1);
          }
          while( i != -1 ) {
              String ss = s.substring(lasti, i);
              if (ss.equals("%")) {
                  lasti = i;
                  i++;
                  i = s.indexOf("%", i);
                  if (i != -1) {
                      ss = s.substring(lasti, i);
                  } else {
                      ss = s.substring(lasti);
                  }
                  list.add("+" + ss);
              } else {
                  list.add(" " + ss);
              }
              if (i == -1) {
                  lasti = i;
                  break;
              }
              lasti = i;
              i++;
              i = s.indexOf("%", i);
          }
          if (lasti != -1) {
              list.add(" " + s.substring(lasti));
          }
  
          String[] ret = new String[list.size()];
          for( i = 0; i < list.size(); i++ ) {
              ret[i] = (String) list.get(i);
          }
          return ret;
      }
docs: Splits input string on '%' and returns an array of substrings that can be
  used for multiple scanf. Each substring has a one-char prefix that can
  take one of two values:
  '+' wich indicates that substring can be simply added to the resulting string
  ' ' wich indicates that substring has to be additionally processed.
  
  @param s      Input string
  
  @return splited input string