The Artima Developer Community
Sponsored Link

Java Answers Forum
i need help in string tokenizer in a textfile pls!!!!

1 reply on 1 page. Most recent reply: Dec 1, 2005 2:46 AM by Rajeev Mutalik

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Francis Villaluz

Posts: 1
Nickname: sicnarf
Registered: Oct, 2005

i need help in string tokenizer in a textfile pls!!!! Posted: Oct 16, 2005 8:11 AM
Reply to this message Reply
Advertisement
I am making an application that will read an input in a textfile.In the data, each line contains an employee id, gross income and numchildren. I need to use string tokenizer to separate those information..Here's my program..my program works..but then it shows a different output.I cant figure out whats wrong..It reads the text on the textfile but it is not passed on the employee id and etc..Pls help me....Thank You!

/October 10, 2005
//This program is the application for the employee worker class

import java.io.*;
import java.util.StringTokenizer;

public class EmployeeApp
{
public static void main (String args[])
{

String input;
String deliminator=" ";
StringTokenizer tokenizer;
String line, word;
int wordCount = 0,characterCount=0;


try
{
FileReader inStream = new FileReader("assign2q4.txt");
BufferedReader ins = new BufferedReader(inStream);

input =ins.readLine();

while(input!=null)
{

tokenizer = new StringTokenizer (input,deliminator);
while(tokenizer.hasMoreTokens())
{
word = tokenizer.nextToken();
wordCount++;
System.out.println(word);
}


Employee data= new Employee();


System.out.println(data.toString());
System.out.println("Your net income is $:"+ data.calNetIncome());

input =ins.readLine();

}
ins.close();
}

catch (IOException ex)
{
System.out.println("i/o error:"+ex.getMessage());
ex.printStackTrace();
}

}
}


Rajeev Mutalik

Posts: 57
Nickname: rajmutalik
Registered: Sep, 2002

Re: i need help in string tokenizer in a textfile pls!!!! Posted: Dec 1, 2005 2:46 AM
Reply to this message Reply
Francis, As per the program u have posted here, I dont see u doin anything with the data that u have read from the file. U r just priting it on screen with SOP. U have neither passed the values to Employee class nor have u processed that data in this program itself.

Regards,
Mutalik

Flat View: This topic has 1 reply on 1 page
Topic: error loop boolean Previous Topic   Next Topic Topic: JPG

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use