aboutsummaryrefslogtreecommitdiff
path: root/tests/BugTok.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/BugTok.java')
-rw-r--r--tests/BugTok.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/BugTok.java b/tests/BugTok.java
new file mode 100644
index 0000000..c5bc445
--- /dev/null
+++ b/tests/BugTok.java
@@ -0,0 +1,38 @@
+import java.util.Vector ;
+class BugTok {
+
+ public static String[] decoupe(String s,String sep) {
+ int index=0, last=0, length=s.length();
+ Vector v = new Vector();
+ if (length!=0) while (true) {
+ index=s.indexOf(sep,last);
+ if (index==-1) {
+ v.add(s.substring(last,length));
+ break;
+ } else if (index<s.length()) {
+ v.add(s.substring(last,index));
+ last=index+1;
+ } else {
+ break;
+ }
+ }
+ String[] tab = new String[v.size()];
+ v.copyInto(tab);
+ return tab;
+ }
+
+ public static void doprint(String[] tab) {
+ System.out.println("------------ "+tab.length+" elements --------------");
+ for (int i=0; i<tab.length;i++) {
+ System.out.println("'"+tab[i]+"'");
+ }
+ System.out.println("------------------------------------------------------");
+ }
+
+ public static void main(String[] arg) {
+ doprint(decoupe("ils ont changé ma chanson"," ")) ;
+ doprint(decoupe(" ils ont changé ma chanson"," ")) ;
+ doprint(decoupe("\u0003ils\u0003ont\u0003\u0003changé ma chanson","\u0003")) ;
+ doprint(decoupe(""," ")) ;
+ }
+}