EOL is not working and uncheck or unsafe operation

Reply

Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

EOL is not working and uncheck or unsafe operation

 
0
  #1
Dec 7th, 2006
  1. import java.io.*;
  2.  
  3. class Tokenizer
  4. {
  5. public static void main( String args[] ) throws Exception
  6. {
  7. String sample = "myfile.txt";
  8. InputStreamReader in;
  9. FileInputStream file = new FileInputStream(sample);
  10. in = new InputStreamReader( file);
  11. StreamTokenizer parser = new StreamTokenizer( in );
  12.  
  13. while ( parser.nextToken() != StreamTokenizer.TT_EOF )
  14. {
  15. if ( parser.ttype == StreamTokenizer.TT_WORD)
  16. System.out.println( "A word: " + parser.sval );
  17. else if ( parser.ttype == StreamTokenizer.TT_NUMBER )
  18. System.out.println( "A number: " + parser.nval );
  19. else if ( parser.ttype == StreamTokenizer.TT_EOL )
  20. System.out.println( "EOL" );
  21. else
  22. System.out.println( "Other: " + (char) parser.ttype );
  23. }
  24. }
  25. }

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

  1. import java.util.*;
  2. public class State{
  3. String id;
  4. boolean Start,Final;
  5.  
  6. List trans= new ArrayList();
  7.  
  8.  
  9. int counter;
  10. //constructer
  11. public State(String name){
  12. id=name;
  13. Start=false;
  14. Final=false;
  15.  
  16.  
  17.  
  18. }
  19. //set the state as a start state
  20. public void setAsStart(){
  21. Start=true;
  22. }
  23. //set the state as a final state
  24. public void setAsFinal(){
  25. Final=true;
  26. }
  27. //returns true if the state is a start state
  28. public boolean isStart(){
  29. return Start;
  30. }
  31. //returns true if state is a final state
  32. public boolean isFinal(){
  33. return Final;
  34. }
  35. //add a transition to a state
  36. //this method adds a transition until the array is full. if the array is already full the catch will catch it
  37. public void addTransition(Transition t){
  38. trans.add(t);
  39. }
  40. public int getNumOfTransitions(){
  41. return trans.size();
  42. }
  43.  
  44. }

--------------------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???
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: EOL is not working and uncheck or unsafe operation

 
0
  #2
Dec 7th, 2006
StreamTokenizer(InputStream is)
Deprecated. As of JDK version 1.1, the preferred way to tokenize an input stream is to convert it into a character stream, for example:
Reader r = new BufferedReader(new InputStreamReader(is));
StreamTokenizer st = new StreamTokenizer(r);
Why are you using a deprecated constructor?
You should ALWAYS avoid ANY deprecated method or class.

TT_EOL indicates that the end of line has been read. The field can only have this value if the eolIsSignificant method has been called with the argument true.
Did you even read the Javadoc?
It says quite clearly that you MUST take a very specific action to ever get that flag returned at all, an action you didn't take.

i got this error. what did i do wrong???
That's not an error, it's a warning.
You're compiling against a 1.5 compiler using code that uses collections without properly typing them.
Read up on generics.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 112
Reputation: Covinus is an unknown quantity at this point 
Solved Threads: 0
Covinus's Avatar
Covinus Covinus is offline Offline
Junior Poster

Re: EOL is not working and uncheck or unsafe operation

 
0
  #3
Dec 14th, 2006
sorry for the late reply. got busy.

anyway i just started learning a few IO stuff on java. The first code was actually taken from the internet. I was searching for lessons bout tokenizers.
so it means the site was teaching wrong stuff.

[quote]That's not an error, it's a warning.
You're compiling against a 1.5 compiler using code that uses collections without properly typing them.
Read up on generics.[quote]

ok i think il do a further study on that.

thanks anyway
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: EOL is not working and uncheck or unsafe operation

 
0
  #4
Dec 15th, 2006
not necessarilly wrong so much as heavily outdated.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC