Results 1 to 7 of 7
  1. #1
    janroz is offline Member
    Join Date
    Jan 2012
    Posts
    16
    Rep Power
    0

    Default what is tokenizer all about?

    can someone help me with tokenizer please? can you give me examples? thanks

  2. #2
    stchman's Avatar
    stchman is offline Member
    Join Date
    Apr 2011
    Location
    Saint Louis, Missouri
    Posts
    97
    Rep Power
    0

    Default 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.

  3. #3
    janroz is offline Member
    Join Date
    Jan 2012
    Posts
    16
    Rep Power
    0

    Default 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; }






















    }

  4. #4
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default Re: what is tokenizer all about?

    can you please give an example how the input file looks like with two employees?

  5. #5
    janroz is offline Member
    Join Date
    Jan 2012
    Posts
    16
    Rep Power
    0

    Default Re: what is tokenizer all about?

    Quote Originally Posted by j2me64 View Post
    can you please give an example how the input file looks like with two employees?
    ok sure! it should be like this! the program should ask "Enter Employee ID:" and if i enter ID no. 2006-0031
    and then the output should be like this:

    EmployeeID : 2006-0031
    Lastname : SULLIVAN
    Firstname : Jamie
    Position : Worker
    Rank : 2
    Salary Rate : Php 350.00/day

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: what is tokenizer all about?

    Quote Originally Posted by j2me64 View Post
    can you please give an example how the input file looks like with two employees?
    Quote Originally Posted by janroz View Post
    ok sure! it should be like this! the program should ask "Enter Employee ID:" and if i enter ID no. 2006-0031
    and then the output should be like this:

    EmployeeID : 2006-0031
    Lastname : SULLIVAN
    Firstname : Jamie
    Position : Worker
    Rank : 2
    Salary Rate : Php 350.00/day
    :headdesk:
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default Re: what is tokenizer all about?

    Quote Originally Posted by janroz View Post
    ok sure! it should be like this! the program should ask "Enter Employee ID:" and if i enter ID no. 2006-0031
    and then the output should be like this:
    Ok, I got the idea. But I still don't understand why you want to use a tokenizer so I asked for an example that show how the data/records are stored in the input file. My request is still opened.

Similar Threads

  1. Tokenizer help!
    By joeyalf in forum New To Java
    Replies: 4
    Last Post: 12-07-2011, 12:46 AM
  2. Tokenizer
    By skaterboy987 in forum New To Java
    Replies: 7
    Last Post: 10-21-2011, 05:07 AM
  3. Need help with string tokenizer
    By ShortIt in forum New To Java
    Replies: 1
    Last Post: 02-18-2011, 07:04 PM
  4. String Tokenizer help
    By GreenTea in forum New To Java
    Replies: 4
    Last Post: 10-30-2010, 02:44 AM
  5. String Tokenizer
    By hussainian in forum Advanced Java
    Replies: 1
    Last Post: 03-16-2010, 08:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •