Results 1 to 4 of 4
  1. #1
    Rio123 is offline Member
    Join Date
    Aug 2014
    Posts
    1
    Rep Power
    0

    Question Splitting values from a file with stringtokenizer and storing it in another class

    Hi

    I'm new to java.

    I have a Product class with getters and setters.

    eg. setProdType & getProdType

    I want to store the values from a file into that
    StringTokenizer token = new StringTokenizer(line,"**");

    while(token.hasMoreElements())
    {
    int p.setProdType = Integer.parseInt(token.nextElement().toString());
    }
    Last edited by Rio123; 08-26-2014 at 11:41 AM.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    946
    Rep Power
    2

    Default Re: Splitting values from a file with stringtokenizer and storing it in another class

    I think half your post is missing. There is no question.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: Splitting values from a file with stringtokenizer and storing it in another class

    Java Code:
    int p.setProdType = ...
    Good luck getting that to compile.

  4. #4
    AlexGraal is offline Seńor Member
    Join Date
    Jan 2014
    Posts
    184
    Rep Power
    0

    Default Re: Splitting values from a file with stringtokenizer and storing it in another class

    In case you ever come back....

    Java Code:
    String message = "This is a message!";
    String[] tokens = message.split(" ");
    for(int i = 0; i < tokens.length; i++) {
         System.out.println(tokens[i]);
    }
    That will print:
    This
    is
    a
    message!

Similar Threads

  1. Storing multiple int values...?
    By Cellie in forum New To Java
    Replies: 13
    Last Post: 05-21-2014, 09:44 AM
  2. Storing object with int values in Arraylist.
    By Zigster in forum New To Java
    Replies: 12
    Last Post: 05-26-2012, 09:49 PM
  3. XML read and storing values
    By LiveStrong-2011 in forum New To Java
    Replies: 1
    Last Post: 05-31-2011, 11:04 AM
  4. Storing a string in StringTokenizer
    By kgkamaraj in forum New To Java
    Replies: 3
    Last Post: 02-12-2010, 01:58 PM
  5. question on how to check values before storing
    By SMHouston in forum New To Java
    Replies: 19
    Last Post: 09-21-2009, 10:54 PM

Posting Permissions

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