2

This is an example of the text that I need to manipulate:

YEAR (space) MONTH (space) NAME (space)

YEAR (space) MONTH (space) NAME (space)

YEAR (sapce) MONTH (space) NAME (space)

YEAR (sapce) MONTH (space) NAME (space) ...

How would one go about creating an array using only the values in one column? e.g the second column (months) or the last column (names)

Jordan
  • 305
  • 3
  • 13
  • Reading an entire line and splitting on space gives you an array whose elements make up one row. Use array indices to get the desired pieces of information. – Timbits Sep 04 '11 at 04:59

3 Answers3

4

read each line and split on space, and reformat the array..

read each line and use a substring to add to the array..

read each line and use regular expression..

miki
  • 695
  • 3
  • 8
3

Take a look at the java.util.Scanner class, specifically the hasNext and next methods.

TofuBeer
  • 60,850
  • 18
  • 118
  • 163
0

Read this answer. See also the split method of String Class in Java Api.

Community
  • 1
  • 1
Alberto Solano
  • 7,972
  • 3
  • 38
  • 61