static void printSpiralMatrix(int[][] matrix, int rows, int columns){
        int columnIndex1 = 0;
        int columnIndex2 = columns-1;
        int rowIndex1 = 0;
        int rowIndex2 = rows-1;
        int indexVisited = 1;
        int i;
        while(indexVisited <= columns*rows){
            for(i = columnIndex1; i <= columnIndex2; i++){
                if(indexVisited == 1){
                    System.out.print(matrix[rowIndex1][i]);
                }else{
                    System.out.print("," + matrix[rowIndex1][i]);  
                }
                indexVisited++;
            }
            if(!(indexVisited <= columns*rows)) break;
            for(i = rowIndex1 + 1; i <= rowIndex2;i++){
                System.out.print("," + matrix[i][columnIndex2]);
                indexVisited++;
            }
            if(!(indexVisited <= columns*rows)) break;
            
            for(i = columnIndex2 - 1; i >= columnIndex1; i--){
                System.out.print("," + matrix[rowIndex2][i]);
                indexVisited++;
            }
            if(!(indexVisited <= columns*rows)) break;
            for(i = rowIndex2 - 1; i >= rowIndex1 + 1; i--){
                System.out.print("," + matrix[i][columnIndex1]);
                indexVisited++;
            }
            columnIndex1++;
            columnIndex2--;
            rowIndex1++;
            rowIndex2--;
        }
    }