Wednesday, 19 October 2016

Java Tutorial : Java IO (Java StreamTokenizer - How to tokenize a word)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=oL7fVykCUYA&list=UUhwKlOVR041tngjerWxVccw

StreamTokenizerDemo.java
import java.io.IOException;
import java.io.StreamTokenizer;
import java.io.StringReader;

public class StreamTokenizerDemo
{

    public static void main(String[] args) throws IOException
    {
        StringReader stringReader = new StringReader("Peter welcome to India");
        StreamTokenizer tokenizer = new StreamTokenizer(stringReader);
        /*
         * TT_EOL is used to determine end of line
         */
        while (tokenizer.nextToken() != StreamTokenizer.TT_EOF)
        {
            /*
             * sval-The string value of the token, if the
             * token was a string (word)
             */
            System.out.println(tokenizer.sval);
        }

    }

}
Output
Peter
welcome
to
India

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_StreamTokenizerDemo_word_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/afab0ff1466aae3a6d02c0935e804f2f099cf483/BasicJava/JavaIODemo_StreamTokenizerDemo_word_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge