Program crashes on command line
<p>I have a problem with this function with have to read a data from file and place it into an array which is used to store data. moreover it have to print out the data that is received. My program is crashing, and I think it is because of this function. I will post my program under the function. it is too long.</p>

<pre><code>public static int ReadFile(double[][] docs, int count) throws NumberFormatException, IOException{
    int i;
    String filename;
    filename=cin.readLine();
    BufferedReader fin =new BufferedReader(new FileReader(filename));
    String line = fin.readLine();
    // read the first lineString line;
    i=1;
    double d0,d1,d2,d3;
    System.out.print("\nThe following documet(s) were read from "+filename+"\n");
    while (line != null) { // do while there is something to read from the file
    String[] splits = line.split(","); // split the line
    d0=Double.parseDouble(splits[0]);
    d1=Double.parseDouble(splits[1]);
    d2=Double.parseDouble(splits[2]);
    d3=Double.parseDouble(splits[3]);
    /* print splitted substring from the line*/
    docs[count][0]=d0;
    docs[count][1]=d1;
    docs[count][2]=d2;
    docs[count][3]=d3;
    System.out.format("\n\nDocument %d:",i);
    System.out.format("\n Number of sentence: %.1f",docs[count][0]);
    System.out.format("\n Number of words: %.1f",docs[count][1]);
    System.out.format("\n Number of syllables: %.1f",docs[count][2]);
    System.out.format("\n Percentage of hard words: %.2f",docs[count][3]);
    if(docs[count][0]&lt;0 || docs[count][1]&lt;0 || docs[count][2]&lt;0 || docs[count][3]&gt;100 ||docs[count][3]&lt;0)
    { i--; count--;System.out.print("\nERROR: Document cannot be added due to invalid input!"); count--;}
    i++;
    count++;

        // next line for while-loop
    line = fin.readLine();}
    System.out.print("\nRead "+(i-1)+"document(s)info from the file.\n\n");
    return count;
    }
</code></pre>

<p>This is my program. It crashes when I try to run it on command line . Please check it out....)</p>

<pre><code>import java.io.*;



public class Pro3_makhayev {
public static BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));

    /**
     * @param args
     * @throws IOException 
     */
//***********************Display******************************************************************//
    public static void DisplayMenu() 
    {
        String menu = 
                "                                       JAVA READABILITY CALCULATION\n"+

"\n ------------                            ----------------------                                  ---------"+
"\n| Docs Info  |                          | Readability Scores   |                                | General |"+
"\n ------------                            ----------------------                                  ---------"+
"\n1 - Enter Document Info                 6 - Display FRE and FOG Scores Sorted by FRE            9 - Clear Database"+
"\n2 - Read Document Info From a File      7 - Display FRE and FOG Scores Sorted by FOG            Q - Quit"+
"\n3 - Change Info for a Single Document   8 - Display Average FRE and FOG Scores"+
"\n4 - Delete a Single Document"+
"\n5 - Display Document Info\n";
        System.out.format("%s",menu);
        System.out.print("\nEnter choice: ");




    }
//*******************************choice1**********************************************//

    public static int EnterDocsInfo(double[][] docs, int count) throws IOException
    {   
    int num_docs=0;
    boolean data;
        for(;count&lt;20;count++)
    { 
        data=EnterSingleInfo(docs, count);

        if(data==false)
        {   break;
         }
        else if(data=true)
        {
            num_docs++;
            continue;
        }

    }
        if(count==20)
        {System.out.print("\nERROR: Database is full. No more documents will be accepted!\n");
         }
        System.out.format("\nYou entered %d new document(s) to the database.\n\n",num_docs);  
    return count;}
//*******************************choice2**********************************************//

    public static int ReadFile(double[][] docs, int count) throws NumberFormatException, IOException{
int i;
String filename;
filename=cin.readLine();
BufferedReader fin =new BufferedReader(new FileReader(filename));
String line = fin.readLine();
// read the first lineString line;
i=1;
double d0,d1,d2,d3;
System.out.print("\nThe following documet(s) were read from "+filename+"\n");
while (line != null) { // do while there is something to read from the file
String[] splits = line.split(","); // split the line
d0=Double.parseDouble(splits[0]);
d1=Double.parseDouble(splits[1]);
d2=Double.parseDouble(splits[2]);
d3=Double.parseDouble(splits[3]);
/* print splitted substring from the line*/
docs[count][0]=d0;
docs[count][1]=d1;
docs[count][2]=d2;
docs[count][3]=d3;
System.out.format("\n\nDocument %d:",i);
System.out.format("\n Number of sentence: %.1f",docs[count][0]);
System.out.format("\n Number of words: %.1f",docs[count][1]);
System.out.format("\n Number of syllables: %.1f",docs[count][2]);
System.out.format("\n Percentage of hard words: %.2f",docs[count][3]);
if(docs[count][0]&lt;0 || docs[count][1]&lt;0 || docs[count][2]&lt;0 || docs[count][3]&gt;100 ||docs[count][3]&lt;0)
{ i--; count--;System.out.print("\nERROR: Document cannot be added due to invalid input!"); count--;}
i++;
count++;

    // next line for while-loop
line = fin.readLine();}
System.out.print("\nRead "+(i-1)+"document(s)info from the file.\n\n");
return count;
}

//*******************************choice3**********************************************//    
public static void ChangeDocInfo(double[][] docs, int count) throws IOException
{  int changedoc=0;

if(count==0)
{
    System.out.print("\nERROR: No documents stored in the database!\n\n");
}
else{
System.out.print("\nEnter document number to change: ");
    do{ try{
      changedoc=Integer.parseInt(cin.readLine());}

     catch(NumberFormatException e) 
 {changedoc=Get_Int();}
     if(changedoc&gt;count)
     {System.out.print("  ERROR: Invalid document number!");
     System.out.print("\n\nEnter document number to change: ");}
     else if(changedoc&lt;=0)
     {changedoc=GetPosInt();}

    }while(!(changedoc&lt;=count &amp;&amp; changedoc&gt;0));


    docs[changedoc-1][0]=GetSentences(changedoc-1);
  if(docs[changedoc-1][0]&gt;0)
    { 
      docs[changedoc-1][1]=GetWords();
      docs[changedoc-1][2]=GetSyllables();
      docs[changedoc-1][3]=GetPercentage();
        System.out.print("\n");}}

}


//*******************************choice4**********************************************//

public static int DeleteDoc(double[][]docs , int count) throws IOException
{  int i=0, j=0;
    int docdelete=0;
    if(count==0)
    {
        System.out.print("\nERROR: No documents stored in the database!\n\n\n");
    }
    else 
    {
        System.out.print("\nEnter document number to delete: ");
        do{ try{
          docdelete=Integer.parseInt(cin.readLine());}

         catch(NumberFormatException e) 
     {docdelete=Get_Int();}
        if(docdelete==0)
        {docdelete=GetPosInt();}
        if((docdelete-1)&gt;count)
         {System.out.print("  ERROR: Invalid document number!\n");
         System.out.print("\nEnter document number to delete: ");}

        }while(!((docdelete-1)&lt;count &amp;&amp; docdelete&gt;0));
        for(i=(docdelete-1);i&lt;count;i++)
          {  
            docs[i][0]=docs[i+1][0];
            docs[i][1]=docs[i+1][1];
            docs[i][2]=docs[i+1][2];
            docs[i][3]=docs[i+1][3];
            docs[i][4]=docs[i+1][4];
            docs[i][5]=docs[i+1][5];

          }
         for(;j&lt;6;j++)
         {docs[i][j]=0.0;}
         System.out.print("\n");
        count--;
        }
   return count;
}
//*******************************choice5**********************************************//
public static void DisplayDocsInfo(double[][] docs, int count)
{   int i=0;
   if(count==0)
   {System.out.print("\nERROR: No documents stored in the database!\n\n");}
   else{
           System.out.format("\n\nThere are %d document(s) stored in the database.",(count));
           System.out.print("\n\n                # Sentences        # Words    # Syllables   % Hard Words");
           System.out.format("\n-------------------------------------------------------------------------");
           for(;i&lt;count;i++)
       {System.out.format("\nDocument%3d:%15.0f%15.0f%15.0f%15.0f",(i+1),docs[i][0],docs[i][1],docs[i][2],docs[i][3]);
          }
System.out.print("\n\n");
}}


//*******************************choice6&amp;7**********************************************//

public static void DisplayScoresFreFog(double[][]docs, int count , boolean FRE_FOG)
{   
    String Interpret = null;
int i;
double [][] orderFRE= new double[20][3];

if(count==0)
System.out.print("\nERROR: No documents stored in the database!\n\n");
else{

    GetFREandFOG(docs,count);



System.out.format("\nThere are %d document(s) stored in the database.", count);
System.out.print("\n                FRE Score    FOG Score      Interpretation");
System.out.print("\n------------------------------------------------------------");
if(FRE_FOG==true)
{    SortFREFOG(1, orderFRE,docs, count);

 for(i=0;i&lt;count;i++)
 {

 if(orderFRE[i][1]&gt;=90)
        Interpret="Very easy";
    else if(orderFRE[i][1]&gt;=80)
        Interpret="Easy";
    else if(orderFRE[i][1]&gt;=70)
        Interpret="Fairly easy";
    else if(orderFRE[i][1]&gt;=60)
        Interpret="Standard";
    else if(orderFRE[i][1]&gt;=50)
        Interpret="Fairly difficult";
    else if(orderFRE[i][1]&gt;=30)
        Interpret="Difficult";
    else if(orderFRE[i][1]&lt;30)
        Interpret="Very confusing";
 System.out.format("\nDocument %2.0f:%13.3f%13.3f%20s",orderFRE[i][0],orderFRE[i][1],orderFRE[i][2], Interpret);

 }
 System.out.print("\n");
 }
else if(FRE_FOG==false)
{     SortFREFOG(2, orderFRE,docs, count);
     for(i=0;i&lt;count;i++)
     {    

         if(orderFRE[i][1]&gt;=90)
                Interpret="Very easy";
            else if(orderFRE[i][1]&gt;=80)
                Interpret="Easy";
            else if(orderFRE[i][1]&gt;=70)
                Interpret="Fairly easy";
            else if(orderFRE[i][1]&gt;=60)
                Interpret="Standard";
            else if(orderFRE[i][1]&gt;=50)
                Interpret="Fairly difficult";
            else if(orderFRE[i][1]&gt;=30)
                Interpret="Difficult";
            else if(orderFRE[i][1]&lt;30)
                Interpret="Very confusing";
         System.out.format("\nDocument %2.0f:%13.3f%13.3f%20s",orderFRE[i][0],orderFRE[i][1],orderFRE[i][2], Interpret);

     }}}}


//*******************************choice8**********************************************//


public static void DisplayAverageScores(double[][] docs, int count)
{   int i;
 double sum=0, sum2=0; 
    for(i=0;i&lt;count;i++)
    {
        sum=+docs[i][4];
        sum2=+docs[i][5];
    }
    System.out.format("\nFRE average:%5.3f \nFOG average:%5.3f",sum/count,sum2/count);
}

//********************************choice9******************************************//

public static int Delete_The_Database(int count, double[][] docs)
{  int i,j;
for(i=0;i&lt;count;i++)
{ for(j=0;j&lt;6;j++)
    docs[i][j]=0.0;}
return count=0;
}




//---------------------------------Helping Functions--------------------------------------//

//*********************************Enter single Info*****************************************//

public static boolean EnterSingleInfo(double[][] docs, int count) throws IOException
{       docs[count][0]=(double)GetSentences(count);

        if(docs[count][0]==0)
            return false;
        else if(docs[count][0]&gt;0)
        { docs[count][1]=(double)GetWords();
           docs[count][2]=(double)GetSyllables();
           docs[count][3]=GetPercentage();
        }
        return true;
        }


//************Get Positive Integer

public static int GetPosInt() throws IOException
{   int posInt=0;
    do{
    System.out.print("   ERROR: Number must be greater than zero! Try again: ");
    try{posInt=Integer.parseInt(cin.readLine());}
    catch(NumberFormatException e)
    {posInt=Get_Int();}
}while(posInt&lt;0);
return posInt;  
}

//***************Get Integer

public static int Get_Int() throws IOException
{   int number=0;
    do{
     System.out.print("   ERROR: Invalid input! Try again: ");
           try{ number=Integer.parseInt(cin.readLine());}
           catch(NumberFormatException e)
           {number=100000000;}
           if(number!=100000000)
               return number;
}while(number==100000000);
return number;
}
//********************Get Nonnegative Integer

public static int GetNonnegInt() throws IOException
{  int NonNegNum=0;
do{
    System.out.print("   ERROR: Number must be greater or equal to zero! Try again: ");
    try{NonNegNum=Integer.parseInt(cin.readLine());}
    catch(NumberFormatException e)
    {NonNegNum=Get_Int();}
}while(NonNegNum&gt;=0);
return NonNegNum;

}

//*********************Get Percentage 

public static double GetPercentage() throws IOException
{    double percent = 0;
    System.out.print("Enter percentage of hard words: ");
    do
    {  do{ try{percent=Double.parseDouble(cin.readLine());}
       catch(NumberFormatException e)
       {System.out.print("   ERROR: Invalid input! Try again: ");
          percent=55.55;}
    }while(percent==55.55);
        if(percent&gt;100 || percent&lt;0)
            System.out.print("   ERROR: Percentage must be in [0,100]! Try again: ");
    }while(percent&gt;=100 || percent&lt;=0);
    return percent;
}

//******************Get words

public static int GetWords() throws IOException
{   int words=0;
    System.out.print("Enter number of words: ");
    try {words=Integer.parseInt(cin.readLine());}
    catch(NumberFormatException e)
    {words=Get_Int();}
    if(words&lt;=0)
    words=GetPosInt();
    return words;
}

//****************Get Syllables

public static int GetSyllables() throws IOException
{int syllables=0;
System.out.print("Enter number of syllables: ");
try {syllables=Integer.parseInt(cin.readLine());}
catch(NumberFormatException e)
{syllables=Get_Int();}
if(syllables&lt;=0)
syllables=GetPosInt();
return syllables;}

//*****************Get sentences

public static int GetSentences(int ind) throws IOException
{   int sentences=0;
    System.out.format("\nEnter number of sentences for DOCUMENT %d (0 to quit): ",ind+1);
    try{ sentences=Integer.parseInt(cin.readLine());}
    catch(NumberFormatException e)
    {sentences=Get_Int();}

        if(sentences&lt;0)
            sentences=GetNonnegInt();
    return sentences;

}

//***********************Get FRE &amp; FOG for the table

public static void GetFREandFOG(double[][] docs, int count)
{
    int i;
    for(i=0;i&lt;count;i++)
    {docs[i][4]=CalculateFRE(docs[i][0], docs[i][1],docs[i][2]);
      docs[i][5]=CalculateFOG(docs[i][0], docs[i][1], docs[i][3]);}

}

//******************************SORTING FRE OR FOG************

public static void SortFREFOG(int fre1fog2, double[][] order, double[][] docs, int count)
{    int i,j;
double temp;
    for(i=0;i&lt;count;i++)
    {
        order[i][0]=i+1;
        order[i][1]=docs[i][4];
        order[i][2]=docs[i][5];
    }
  for(i=0;i&lt;count;i++)
  { for(j=i;j&lt;count;j++)
  {
      if(order[j][fre1fog2]&lt;order[i][fre1fog2])
      {temp=order[i][0];
      order[i][0]=order[j][0];
      order[j][0]=temp;
      temp=order[i][1];
      order[i][1]=order[j][1];
      order[j][1]=temp;
          temp=order[i][2];
          order[i][2]=order[j][2];
          order[j][2]=temp;

      }

  }
  }
  }

//---------------------------------------Calculating functions--------------------------------//
public static double CalculateFRE(double nSent, double nWords, double nSyl)
{
    return 206.835-1.1015*(nWords/nSent)-84.6*(nSyl/nWords);
}

public static double CalculateFOG(double nSent, double nWords, double pHard)
{
    return 0.4*(nWords/nSent+pHard);
}









    public static void main(String[] args) throws NumberFormatException, IOException
    {
            String ch = null, myQ="Q", myq="q";
            int choice = 0;
            int count=0;
            double [][] DocInfo = new double[20][6];
            // TODO Auto-generated method stub

                do{DisplayMenu();
               ch =cin.readLine();
               if(ch.equals(myQ) || ch.equals(myq))
               { System.out.print("\nAdios!");
                   System.exit(1);}
               else
               {try{choice=Integer.parseInt(ch);}
               catch(NumberFormatException e)
               {System.out.print("\nERROR: Invalid menu choice!\n");
                  choice=10000000;}

               if(choice==1){
                    count=EnterDocsInfo(DocInfo, count);
                    choice=10000000;
                    }
                    else if(choice==2)
                    {
                        System.out.print("\nEnter file name: ");
                        String filename;
                        filename=cin.readLine();
                        count=ReadFile(DocInfo,  count);

                        choice=10000000;

                    }
                    else if(choice==3)
                    { 
                      ChangeDocInfo( DocInfo, count);
                        choice=10000000;

                    }
                    else if(choice==4)
                    {
                        count=DeleteDoc(DocInfo , count);
                        choice=10000000;

                    }
                    else if(choice==5)
                    {
                        DisplayDocsInfo(DocInfo, count);
                        choice=10000000;

                    }
                    else if(choice==6)
                    {
                        DisplayScoresFreFog(DocInfo, count , true);
                        choice=10000000;

                    }
                    else if(choice==7)
                    {
                        DisplayScoresFreFog(DocInfo, count , false);                    choice=10000000;

                    }
                    else if(choice==8)
                    {
                        DisplayAverageScores(DocInfo,count);choice=10000000;
                    }
                    else if(choice==9)
                    {
                        count=Delete_The_Database(count, DocInfo);
                        System.out.print("\nDatabase cleared!\n");choice=10000000;
                    }

               else if((choice&lt;1 || choice&gt;9) &amp;&amp; choice!=10000000)
               {System.out.print("\nERROR: Invalid menu choice!\n");
                  choice=10000000;}}
               }while(choice==10000000);

    }



}
</code></pre>
