store string tokens in separate variables


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: store string tokens in separate variables

  1. #1
    Join Date
    May 2005
    Posts
    3

    store string tokens in separate variables

    Hi,

    I have a line from a .csv file that i read in, i then slpit the line and print out each token to the screen. what i would like to do is store the value of each token in their own separate variable. can anyone please help me. here is the code i used:

    Code:
    String[] tokens = line.split(",");
    for (int i=0; i<tokens.length; i++)
    System.out.println(tokens[i]);
    1234
    Fri Aug 11
    5678
    C:\Documents and Settings\java.class
    4096

    i want each token above to be stored in separate variables: num, date, num2,filepath, size

    thanks in advance for the help,

    scoobie

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    int num = Integer.parseInt(tokens[0]);
    String date = tokens[1];
    String filepath = tokens[2];

    As long as you know the order the tokens are in, otherwise you're kind of out of luck.

Similar Threads

  1. Replies: 3
    Last Post: 10-03-2005, 12:57 AM
  2. App Object
    By Rob Teixeira in forum .NET
    Replies: 15
    Last Post: 05-31-2002, 04:30 PM
  3. verify local admin
    By Patrick Comeau in forum VB Classic
    Replies: 6
    Last Post: 03-22-2001, 11:50 PM
  4. Please help me -- urgent -- deadlock error
    By chandra in forum VB Classic
    Replies: 0
    Last Post: 06-22-2000, 08:36 AM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 04:21 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center