From 7857320c9e83a87bf708527ec8525fb74debf820 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 9 Apr 2010 20:06:44 +0000 Subject: [PATCH] an example program using StringTokenizer --- .../src/Tests/disjoint/strTokTest/input.txt | 3 ++ Robust/src/Tests/disjoint/strTokTest/makefile | 20 +++++++++++++ .../src/Tests/disjoint/strTokTest/test.java | 30 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 Robust/src/Tests/disjoint/strTokTest/input.txt create mode 100644 Robust/src/Tests/disjoint/strTokTest/makefile create mode 100644 Robust/src/Tests/disjoint/strTokTest/test.java diff --git a/Robust/src/Tests/disjoint/strTokTest/input.txt b/Robust/src/Tests/disjoint/strTokTest/input.txt new file mode 100644 index 00000000..082ba11a --- /dev/null +++ b/Robust/src/Tests/disjoint/strTokTest/input.txt @@ -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 index 00000000..d1155107 --- /dev/null +++ b/Robust/src/Tests/disjoint/strTokTest/makefile @@ -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 index 00000000..ae633ed5 --- /dev/null +++ b/Robust/src/Tests/disjoint/strTokTest/test.java @@ -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(); + } +} -- 2.34.1