import java.io.*;
class Tokenizer
{
public static void main( String args[] ) throws Exception
{
String sample = "myfile.txt";
InputStreamReader in;
FileInputStream file = new FileInputStream(sample);
in = new InputStreamReader( file);
StreamTokenizer parser = new StreamTokenizer( in );
while ( parser.nextToken() != StreamTokenizer.TT_EOF )
{
if ( parser.ttype == StreamTokenizer.TT_WORD)
System.out.println( "A word: " + parser.sval );
else if ( parser.ttype == StreamTokenizer.TT_NUMBER )
System.out.println( "A number: " + parser.nval );
else if ( parser.ttype == StreamTokenizer.TT_EOL )
System.out.println( "EOL" );
else
System.out.println( "Other: " + (char) parser.ttype );
}
}
}
the EOL is not reconize??? Althought i have a \n in my text file it doesnt seem to know its already an EOL.
Question no 2
import java.util.*;
public class State{
String id;
boolean Start,Final;
List trans= new ArrayList();
int counter;
//constructer
public State(String name){
id=name;
Start=false;
Final=false;
}
//set the state as a start state
public void setAsStart(){
Start=true;
}
//set the state as a final state
public void setAsFinal(){
Final=true;
}
//returns true if the state is a start state
public boolean isStart(){
return Start;
}
//returns true if state is a final state
public boolean isFinal(){
return Final;
}
//add a transition to a state
//this method adds a transition until the array is full. if the array is already full the catch will catch it
public void addTransition(Transition t){
trans.add(t);
}
public int getNumOfTransitions(){
return trans.size();
}
}
--------------------Configuration: <Default>--------------------
Note: \\Server3\users\0321468\State.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Process completed.
i got this error. what did i do wrong???