Start New Discussion within our Software Development Community

I am trying to read a CSV file having no. of rows=row and no. of columns=col by the following method:

public static String[][] FileIntoArray(int row, int col, String FileName){
        int Filerow=0;
        int Filecol=0;
        String line;
        String[][] FileArray= new String[row][col];

        File file = new File(FileName);

                BufferedReader bf  = new BufferedReader(new FileReader(file));
                try {
                    while((line = bf.readLine()) != null){

                    StringTokenizer st = new StringTokenizer(line,",");
                    while (st.hasMoreTokens()){
                            FileArray[Filerow][Filecol]= st.nextToken();

                    Filecol = 0;

                }catch (IOException e){
            }catch(FileNotFoundException f){
    return FileArray;


Now suppose, the code reads the file

As you could see, there are some entries absent on 2nd row. So what will it read then if the entries are not present?

This question has already been answered. Start a new discussion instead.