database/src/DbTable.java
public void writeToFile(String outputFileName){//} throws java.io.IOException, FileNotFoundException {

        String[] line = new String[this.entries.size()+1];

        outputFileName += ".txt";
        //try to write to file
        //throws error if file not found aka unable to create
        try {

            PrintWriter writer = new PrintWriter(outputFileName);
            String colNames = new String();
            for (int i = 0; i < this.columnNames.size()-1; i++) {
                colNames += this.columnNames.get(i) + ",";
            }

            colNames += this.columnNames.get(this.columnNames.size() -1);

            line[0] = colNames;

            for (int k = 1; k <= this.entries.size(); k++) {
                for (int y = 0; y < this.entries.size(); y++) {
                       // DataObject curr = this.entries.get(y);
                            for (int p = 0; p < this.columnNames.size(); p++){
                                line[k] += this.entries.get(y).get(columnNames.get(p));
                                line[k] += " ";
                            }
                        line[k] += ("\n");
                }
            }

                for (int l = 0; l <= this.entries.size(); l++) {
                    writer.println(line[l]);
                }

                writer.close();


        }  catch (FileNotFoundException ex) {
            System.out.println("Could not write to file."
                    + outputFileName + " not found");
        } catch (java.io.IOException ex) {
            System.out.println("Error writing to file "
                    + outputFileName);
        }

    }
/**
     * Writes the contents of the table to an output file. The output file has the following format:
     *
     * First line:
     * All column names, with each name separated by a comma
     *
     * Second line:
     * Contents of first data object, with each column value separated by a comma
     *
     * Third line:
     * Contents of second data object, etc.
     *
     *
     * Example: If the DbTable had the columns "id", "coursename", and "meetingtime", and had 3 entries with values:
     * ("123", "comp285", "0900"), ("021", "math150", "1500"), and ("421", "math151", "1000"), then the output file
     * contents would look like:
     *
     * id,coursename,meetingtime
     * 123,comp285,0900
     * 021,math150,1500
     * 421,math151,1000
     *
     *
     * @param outputFileName    Name of the file to write the contents to.  If the file already exists then it will be
     *                          overwritten.
     * @throws                  java.io.IOException if the file cannot be written to
     *
     */
Writes the contents of the table to an output file. The output file has the following format:
First line:
All column names, with each name separated by a comma

Second line:
Contents of first data object, with each column value separated by a comma

Third line:
Contents of second data object, etc.





@param outputFileName    Name of the file to write the contents to.  If the file already exists then it will be
overwritten.
@throws                  java.io.IOException if the file cannot be written to
Writes the contents of the table to an output file . The output file has the following format : First line : All column names with each name separated by a comma Second line : Contents of first data object with each column value separated by a comma Third line : Contents of second data object etc . @param outputFileName Name of the file to write the contents to . If the file already exists then it will be overwritten . @throws java . io . IOException if the file cannot be written to
public void writeToFile(String outputFileName){
        String[] line = new String[this.entries.size()+1];
        outputFileName += ".txt";
        try {
            PrintWriter writer = new PrintWriter(outputFileName);
            String colNames = new String();
            for (int i = 0; i < this.columnNames.size()-1; i++) {
                colNames += this.columnNames.get(i) + ",";
            }
            colNames += this.columnNames.get(this.columnNames.size() -1);
            line[0] = colNames;
            for (int k = 1; k <= this.entries.size(); k++) {
                for (int y = 0; y < this.entries.size(); y++) {
                            for (int p = 0; p < this.columnNames.size(); p++){
                                line[k] += this.entries.get(y).get(columnNames.get(p));
                                line[k] += " ";
                            }
                        line[k] += ("\n");
                }
            }
                for (int l = 0; l <= this.entries.size(); l++) {
                    writer.println(line[l]);
                }
                writer.close();
        }  catch (FileNotFoundException ex) {
            System.out.println("Could not write to file."
                    + outputFileName + " not found");
        } catch (java.io.IOException ex) {
            System.out.println("Error writing to file "
                    + outputFileName);
        }
    }
public void writeToFile ( String outputFileName ) { String [ ] line = new String [ this . entries . size ( ) + 1 ] ; outputFileName += ".txt" ; try { PrintWriter writer = new PrintWriter ( outputFileName ) ; String colNames = new String ( ) ; for ( int i = 0 ; i < this . columnNames . size ( ) - 1 ; i ++ ) { colNames += this . columnNames . get ( i ) + "," ; } colNames += this . columnNames . get ( this . columnNames . size ( ) - 1 ) ; line [ 0 ] = colNames ; for ( int k = 1 ; k <= this . entries . size ( ) ; k ++ ) { for ( int y = 0 ; y < this . entries . size ( ) ; y ++ ) { for ( int p = 0 ; p < this . columnNames . size ( ) ; p ++ ) { line [ k ] += this . entries . get ( y ) . get ( columnNames . get ( p ) ) ; line [ k ] += " " ; } line [ k ] += ( "\n" ) ; } } for ( int l = 0 ; l <= this . entries . size ( ) ; l ++ ) { writer . println ( line [ l ] ) ; } writer . close ( ) ; } catch ( FileNotFoundException ex ) { System . out . println ( "Could not write to file." + outputFileName + " not found" ) ; } catch ( java . io . IOException ex ) { System . out . println ( "Error writing to file " + outputFileName ) ; } }
Writes the contents of the table to an output file.
Writes the contents of the table to an output file .
//} throws java.io.IOException, FileNotFoundException { //try to write to file //throws error if file not found aka unable to create // DataObject curr = this.entries.get(y);