| | |
EOL is not working and uncheck or unsafe operation
![]() |
java Syntax (Toggle Plain Text)
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
java Syntax (Toggle Plain Text)
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???
if you cant hit 2 birds with one stone try hitting just one or you will end up with nothing at all
•
•
•
•
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);
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.
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???
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.
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
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
![]() |
Similar Threads
- Macromedia Flash Player stopped an unsafe operation (Viruses, Spyware and other Nasties)
- Reading from external data file (C++)
Other Threads in the Java Forum
- Previous Thread: Cloning Question
- Next Thread: Validation Check
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows






