I'm getting a NULL POinter Exception at the boldened lines of code! What am I doing wrong?
<pre><code>public class kmeansgeneral {
    public static void main(final String args[]) throws Exception {

        int words = 0;
        int chars = 0;
        int lines = 0;

        String s, sp1;
        StringTokenizer st;
        final ArrayList&lt;Double&gt; x = new ArrayList&lt;Double&gt;();

        final FileReader fr = new FileReader("G:/t1.txt");
        final BufferedReader buf = new BufferedReader(fr);

        // Counting number of words and lines
        while ((s = buf.readLine()) != null) {
            lines++;
            st = new StringTokenizer(s, " ,;:.");

            while (st.hasMoreTokens()) {

                words++;
                s = st.nextToken();
                chars += s.length();

                final Double y = new Double(s);
                x.add(y);

            }

        }

        System.out.println("Word Count : " + words / lines);
        System.out.println("Line Count : " + lines);
        // Counting and printing number of words and lines ENDS

        Double ct[] = new Double[0];
        ct = x.toArray(ct);

        // Input array, values to be read in successively, float
        // double[][] indat = new double[lines][lines*words];
        final double[][] indat = new double[10][10];
        int inval = 0;

        final BufferedReader buf1 = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter K-Value : ");
        sp1 = buf1.readLine();

        final Integer ky = new Integer(sp1);
        final int k = ky;

        System.out.println("K ==  " + k);

        // Now read in input array values, successively

        for (int i = 0; i &lt; lines; i++) {
            for (int j = 0; j &lt; words / lines; j++) {

                indat[i][j] = ct[inval];
                inval++;

                System.out.print(indat[i][j]);
                System.out.print("\t");
            }
            System.out.println();
        }


        // Initial Clusters
        System.out.println("   ");
        System.out.println(k + " seed  points ");

        final double[][] Clusters = new double[k][lines * words];
        // double[][] calcnt = new double[lines][words];
        final double[][] calcnt = new double[1000][1000];
        final double[][] array = new double[k][lines * words];

        System.out.println("Clusters==&gt;");
        // int pos=0;
        for (int i = 0; i &lt; k; i++) {
            for (int j = 0; j &lt; words / lines; j++) {

                Clusters[i][j] = indat[i][j];
                // pos= j;

                System.out.print(Clusters[i][j]);
                System.out.print("\t");
            }
            System.out.println();

        }
        System.out.println("PRINTING VECTOR ELEMENTS:");
        final Vector FinalClusters[][] = new Vector[100][100];

        for (int i = 0; i &lt; k; i++) {
            for (int j = 0; j &lt; words / lines; j++) {
                final String tempString = String.valueOf(Clusters[i][j]);
                FinalClusters[i][j].add(tempString);
            }

        }

        // Inital Cluster Array
        System.out.println("Initial Cluster Array");
        int b = 0;
        final double[] arr = new double[2000];

        for (int i = 0; i &lt; k; i++) {
            for (int j = 0; j &lt; words / lines; j++) {

                arr[b] = Clusters[i][j]; // = indat[i][j];
                System.out.print(arr[b]);
                System.out.print("\t");
                b++;
            }

        }
        System.out.println();


        System.out.println("Centroids");

        for (int i = 0; i &lt; k; i++) {
            for (int j = 0; j &lt; words / lines; j++) {

                calcnt[i][j] = (Clusters[i][j] + indat[k][j]) / 2;

                System.out.print(calcnt[i][j]);
                System.out.print("\t");

            }

        }

        // Claculate Distances

        // System.out.println("MAGIC # 3");

        final double[] dist = new double[k];

        for (int i = 0; i &lt; k; i++) {

            double dis = 0;
            for (int j = 0; j &lt; words / lines; j++) {

                dis = dis + (Math.pow(Clusters[i][j] - indat[k][j], 2));

            }
            dist[i] = (Math.sqrt(dis));
            System.out.println("From Cluster K = " + i + "\t" + "Distance" + dist[i]);
        }

        System.out.println("To Find Minimum Distance ");

        double min = dist[0];

        int y = 0;

        for (int m = 0; m &lt; k; m++) {

            if (dist[m] &lt; min) {
                min = dist[m];
                y = m;
            }
        }
        System.out.print("Min Value =" + min + "\t" + "For Cluster :" + y);

        System.out.println();
        System.out.print("Added Cluster =");
        final double[] temp = new double[lines * (words / lines)];

        for (int j = 0; j &lt; words / lines; j++) {

            temp[j] = indat[k][j];

            System.out.print(temp[j]);
            System.out.print("\t");

        }
        System.out.println();

        final Vector[] vector = new Vector[k];
        for (int i = 0; i &lt; k; i++) {
            vector[i] = new Vector&lt;Object&gt;();
        }

        for (int i = 0; i &lt; words / lines; i++) {
            vector[y].add(String.valueOf(temp[i]));
        }

        System.out.println(Arrays.toString(vector));


    }
}
</code></pre>
