public String[] splitAndRemoveEmptyLines(String str)
    {
        String[] data = str.split("\n");

        //count the non-empty entries
        int count = 0;
        for (int i=0; i < data.length; i++)
        {
            if (!data[i].equals(""))
                count++;
        }

        String ret[] = new String[count];
        count = 0;
        for (int i=0; i < data.length; i++)
        {
            if (!data[i].equals(""))
                ret[count++] = data[i];
        }

        return ret;
    }