Results 1 to 7 of 7
Thread: what is tokenizer all about?
- 01-18-2012, 06:10 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
- 01-18-2012, 07:27 AM #2
Re: what is tokenizer all about?
The StringTokenizer class has basically been replaced by String's split method.
If you aren't programming in Java, well that's just too bad.
I'd rather be using Ubuntu.
- 01-18-2012, 08:00 AM #3
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
Re: what is tokenizer all about?
i have this problem that need to solve this is for the last question i need to solved:
Instructions:
Create a method used to search an employee record from the list of Employee Profiles. You must ask for an employee number as the basis for searching a record. If the employee number exists, display the profile of the employee who owns that employee number. If the record does not exist, display a message to inform the user.
Sample Output: (if the record exists)
Enter Employee ID: 2006-0031
--------------------------------------------------------------------------------------------------------------------------------
EmployeeID : 2006-0031
Lastname : SULLIVAN
Firstname : Jamie
Position : Worker
Rank : 2
Salary Rate : Php 350.00/day
Another Sample Output: (if the record does not exists)
Enter Employee ID: 2006-0000
--------------------------------------------------------------------------------------------------------------------------------
Error: Employee not Found!
and this is my code yet.. please help me what is the next step of coding for the this problem.
import java.io.*;
import java.util.*;
class exam {
public static void main(String [] args) {
String fileName = "Employee.txt", line;
String id, fN, lN, rank, pos;
BufferedReader read = null;
StringTokenizer token = null;
try {
read = new BufferedReader (new FileReader(fileName));
line = read.readLine();
while(line != null){
token = new StringTokenizer(line);
fN = getFirstName(token.nextToken());
lN = getLastName(token.nextToken());
id = getID(token.nextToken());
pos = getPosition(token.nextToken());
rank = getRank(token.nextToken());
displayRecord(id, lN, fN, pos, rank);
line = read.readLine();
}
System.out.println("------------------------------------------");
}
catch (IOException e) {
System.out.println("Error in reading the file '" + fileName);
}
}
static void displayRecord(String id, String lN, String fN, String pos, String rank){
System.out.println("------------------------------------------");
System.out.println("Employee ID : "+id);
System.out.println("Last Name : "+lN);
System.out.println("First Name : "+fN);
System.out.println("Position : "+pos);
System.out.println("Rank : "+rank);
}
static String getFirstName(String fN) { return fN; }
static String getLastName(String lN) { return lN; }
static String getID(String id) { return id; }
static String getPosition(String pos) { return pos; }
static String getRank(String rank) { return rank; }
}
- 01-18-2012, 11:08 PM #4
Re: what is tokenizer all about?
can you please give an example how the input file looks like with two employees?
- 01-19-2012, 06:22 AM #5
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
Re: what is tokenizer all about?
- 01-19-2012, 08:25 AM #6
- 01-19-2012, 10:36 AM #7
Re: what is tokenizer all about?
Similar Threads
-
Tokenizer help!
By joeyalf in forum New To JavaReplies: 4Last Post: 12-07-2011, 12:46 AM -
Tokenizer
By skaterboy987 in forum New To JavaReplies: 7Last Post: 10-21-2011, 05:07 AM -
Need help with string tokenizer
By ShortIt in forum New To JavaReplies: 1Last Post: 02-18-2011, 07:04 PM -
String Tokenizer help
By GreenTea in forum New To JavaReplies: 4Last Post: 10-30-2010, 02:44 AM -
String Tokenizer
By hussainian in forum Advanced JavaReplies: 1Last Post: 03-16-2010, 08:58 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks