an example program using StringTokenizer
authorjjenista <jjenista>
Fri, 9 Apr 2010 20:06:44 +0000 (20:06 +0000)
committerjjenista <jjenista>
Fri, 9 Apr 2010 20:06:44 +0000 (20:06 +0000)
Robust/src/Tests/disjoint/strTokTest/input.txt [new file with mode: 0644]
Robust/src/Tests/disjoint/strTokTest/makefile [new file with mode: 0644]
Robust/src/Tests/disjoint/strTokTest/test.java [new file with mode: 0644]

diff --git a/Robust/src/Tests/disjoint/strTokTest/input.txt b/Robust/src/Tests/disjoint/strTokTest/input.txt
new file mode 100644 (file)
index 0000000..082ba11
--- /dev/null
@@ -0,0 +1,3 @@
+dude  man      guy
+   lady  woman  chica
+ gato  cat kitty
diff --git a/Robust/src/Tests/disjoint/strTokTest/makefile b/Robust/src/Tests/disjoint/strTokTest/makefile
new file mode 100644 (file)
index 0000000..d115510
--- /dev/null
@@ -0,0 +1,20 @@
+PROGRAM=test
+
+SOURCE_FILES=$(PROGRAM).java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+
+BSFLAGS= -mainclass Test
+
+all: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+       $(BUILDSCRIPT) $(BSFLAGS) $(DEBUGFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+       rm -f  $(PROGRAM).bin
+       rm -fr tmpbuilddirectory
+       rm -f  *~
+       rm -f  *.dot
+       rm -f  *.png
+       rm -f  aliases.txt
diff --git a/Robust/src/Tests/disjoint/strTokTest/test.java b/Robust/src/Tests/disjoint/strTokTest/test.java
new file mode 100644 (file)
index 0000000..ae633ed
--- /dev/null
@@ -0,0 +1,30 @@
+
+public class Test {
+  static public void main( String[] args ) {
+
+    FileInputStream in = new FileInputStream( "input.txt" );
+
+    String strLine = in.readLine();
+
+    while( strLine != null ) {
+
+      System.out.println( "Read line:["+strLine+"]" );
+      System.out.print  ( "  with tokens: " );
+
+      StringTokenizer tokenizer = 
+        new StringTokenizer( strLine, // string to tokenize
+                             " " );   // delimiters
+
+      while( tokenizer.hasMoreTokens() ) {
+        String token = tokenizer.nextToken();
+        System.out.print( "("+token+"), " );
+      }
+
+      System.out.println( "" );
+      
+      strLine = in.readLine();
+    }
+
+    in.close();
+  }   
+}