hi there,
i'm trying to count the number of rows and columns that are in the excel sheet occupied by data. i have extracted the data and printed also.. but the array declaration is static... i want it dynamic.. coz there may be thousands of data and hence static doesnt work. my code is:
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws FileNotFoundException, IOException {
String [][] numbers = new String [6][2];
File file = new File("E:\\anish.csv");
BufferedReader bufRdr = new BufferedReader(new FileReader(file));
String line = null;
int row = 0;
int col = 0;
//read each line of text file
while((line = bufRdr.readLine()) != null && row < 6)
{
StringTokenizer st = new StringTokenizer(line,",");
while (st.hasMoreTokens())
{
//get next token and store it in the array
numbers[row][col] = st.nextToken();
col++;
}
col = 0;
row++;
}
for (int i=0; i<numbers.length; i++)
{
for (int j=0; j<numbers[i].length; j++)
{
System.out.println(numbers[i][j]);
}
System.out.println("-----");
}
}
}
i know that there are 6 rows n 2 columns.. but every time the data will be changed.. so i need dynamic array declaration according to the number of rows and columns that are occupied by data.. so how can i do that???
can anyone help me???
thankx in advance!!!