array value reading issue

In the main method  i am calling a method 'checkDatabases' like below
checkDatabases(rows);

method implementation is like this

private static void checkDatabases(String[] rows) {

where I am able to read all array values
using


System.out.println("rows--->"+Arrays.deepToString(rows));

rows--->999|5555|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
998|5554|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
997|5553|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
996|5552|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH



but when I read the individual values like below

String yourHelloString = rows[0][0];
      String yourWorldString = rows[0][1];
      String yourTGoodbyeString = rows[1][0];
      String yourPlanetString = rows[1][1];

getting error as
The type of expression must be an array type but it resolved to string.

I need to read these values and send send it to query to check againest database.
Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
LVL 7
gudii9Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CEHJConnect With a Mentor Commented:
I was under the impression that i'd already answered this actually
System.out.println("rows--->"+Arrays.deepToString(rows));

rows--->999|5555|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
998|5554|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
997|5553|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
996|5552|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH

Open in new window


The above can't be right, as it's not the output from printing any kind of array
0
 
Ajay-SinghConnect With a Mentor Commented:
rows is a single dimensional array and you are accessing it as a 2-dimensional array.
0
 
gudii9Author Commented:
oh. How Do I know it as 1 Dimentional or 2 Dimentional.  I was under wrong impression till now.

how do I access it in this case of 1 Dimentional 'rows; value to read first two values of each line(bolded values)

999|5555|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
998|5554|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
997|5553|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
996|5552|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH

The text document number of lines, number of cells or values are not fixed which is dynamic as well. How to cover that one as well.
0
 
imladrisConnect With a Mentor Commented:
>How Do I know it as 1 Dimentional or 2 Dimentional

It is 1 dimensional in this case, because the definition of the argument is:

private static void checkDatabases(String[] rows) {

That says that rows is 1 dimensional. A two dimensional argument would have been "String[][] rows".

Where do you get the argument that you pass to checkDatabases?
0
 
gudii9Author Commented:
>>Where do you get the argument that you pass to checkDatabases?
I have my custom code to retrieve the data in main method before this method call
      String strContent = BufferStor.retrieveData("C:\\Test.txt");
      String [] rows = strContent.split(genProp.getString("row.seperator"));


>>>System.out.println("rows--->"+Arrays.deepToString(rows));
is already giving following  required values to me in console.

rows--->999|5555|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
998|5554|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
997|5553|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
996|5552|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH

All i need to do is to get only first two values of each row(the italicised one) and i need to pass them to datase query either directly or send to collection object and collect from it  whichever is simpler and easier

999|5555|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
998|5554|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
997|5553|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
996|5552|6666|PPP|9/9/2009 15:49|1444-AAA_111|FINISH
Test.txt
0
All Courses

From novice to tech pro — start learning today.