Explain Stream Tokenizer?

Answers were Sorted based on User's Feedback



Explain Stream Tokenizer?..

Answer / neema

The StreamTokenizer class takes an input stream and parses
it into "tokens", allowing the tokens to be read one at a
time.

Reader r = new BufferedReader(new InputStreamReader(is));
StreamTokenizer st = new StreamTokenizer(r);

Is This Answer Correct ?    7 Yes 1 No

Explain Stream Tokenizer?..

Answer / qim2010

The StreamTokenizer class can tokenizer a Reader into
tokens. For instance, in the string "Mary had a little lamb"
each word is a separate token.

We need to move through the tokens in the underlying Reader
by calling the nextToken() method in a loop. After each
call to nextToken() the StreamTokenizer has several fields
you can read to see what kind of token was read, it's value
etc. These fields are:

ttype The type of token read (word, number, end of line)
sval The string value of the token, if the token was a
string (word)
nval The number value of the token, if the token was a
number.

Is This Answer Correct ?    2 Yes 1 No

Explain Stream Tokenizer?..

Answer / srinu

Stream Tokenizer from java.util package this class
implements Enumeration interface.This class break the string
into tokens with take parameter as delimeter

EX:-
import java.util.*;
public class Strtok
{

public static void main(String [] args)
{

String Demo = "This is a string that we want to tokenize";
StringTokenizer Tok = new StringTokenizer(Demo);
int n=0;
while (Tok.hasMoreElements())
System.out.println("" + ++n +": "+Tok.nextElement());
}
}

Is This Answer Correct ?    2 Yes 2 No

Explain Stream Tokenizer?..

Answer / ravikiran(aptech mumbai)

StringTokenizer is a class of java.util package.
It's main purpose is to break the string into tokens with
reference to a delimeter

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More Core Java Interview Questions

What is a default method?

0 Answers  


what is marker interface ? what is the necessity of it?

5 Answers   Accenture, Newgen,


How do you input a string in java?

0 Answers  


How many types of JVM's (OR) Name of the JVM's which are used in Tomcat & Weblogic servers ?

1 Answers   TCS,


What is meant by serialisation and deserialisation?

4 Answers  






how to use finalize()Method to resources

4 Answers   TCS,


Can I override protected method in java?

0 Answers  


Convert a BST into a DLL and DLL to BST in place.

0 Answers   Amazon,


Why is an interface be able to extend more than one interface but a class can’t extend more than one class?

0 Answers  


What is a local block?

0 Answers   Global Logic,


Can a double value be cast to a byte?

3 Answers  


What are the different types of sorting in java?

0 Answers  


Categories