I have to read a file in format char, int string.
I can easily do it in the form - int int, string e.g. 12 34 the cat sat on the mat(which is what I want to process and output)
code below.
tokenType = inputStream.nextToken();
while (tokenType != StreamTokenizer.TT_EOF)
{
firstNo= (float)inputStream.nval; inputStream.nextToken();
secondNo = inputStream.nval;
thirdstring = inputStream.Sval;
System.out.println(firstNo+"\t"+secondNo+"\n"+thirdstring );
tokenType = inputStream.nextToken();
}
}
but when theres a character at the begining or a string, int, string I can only get the first word(shown below) of the string instead of the whole title.
in.nextToken();
while (in.ttype!=StreamTokenizer.TT_EOF)
{
if(in.ttype==StreamTokenizer.TT_WORD){
type=in.sval;
}
else{
System.out.println("Wrong file format");
}
if(in.nextToken()==StreamTokenizer.TT_NUMBER){
v=in.nval;
}
else{
System.out.println("Wrong file format");
}
if(in.nextToken()==StreamTokenizer.TT_WORD){
\\here
show=in.sval;
in.nextToken();
}
}
it will get the first word of the last string.
I want to put the foloowing code where "\\here" is to get the rest of string
show+=in.sval;
show+=" ";
if(in.nextToken()==StreamTokenizer.TT_EOL)
{
break;
}
show=" ";
but it doesn't like EOL, nothing gewts printed out???