public static <U, I> void saveDataModel(final TemporalDataModelIF<U, I> dm, final String outfile, final boolean overwrite, String delimiter)
            throws FileNotFoundException, UnsupportedEncodingException {
        if (new File(outfile).exists() && !overwrite) {
            System.out.println("Ignoring " + outfile);
        } else {
            PrintStream out = new PrintStream(outfile, "UTF-8");
            for (U user : dm.getUsers()) {
                for (I item : dm.getUserItems(user)) {
                    Double pref = dm.getUserItemPreference(user, item);
                    Iterable<Long> time = dm.getUserItemTimestamps(user, item);
                    if (time == null) {
                        out.println(user + delimiter + item + delimiter + pref + delimiter + "-1");
                    } else {
                        for (Long t : time) {
                            out.println(user + delimiter + item + delimiter + pref + delimiter + t);
                        }
                    }
                }
            }
            out.close();
        }
    }
public static < U , I > void saveDataModel ( final TemporalDataModelIF < U , I > dm , final String outfile , final boolean overwrite , String delimiter ) throws FileNotFoundException , UnsupportedEncodingException { if ( new File ( outfile ) . exists ( ) && ! overwrite ) { System . out . println ( "Ignoring " + outfile ) ; } else { PrintStream out = new PrintStream ( outfile , "UTF-8" ) ; for ( U user : dm . getUsers ( ) ) { for ( I item : dm . getUserItems ( user ) ) { Double pref = dm . getUserItemPreference ( user , item ) ; Iterable < Long > time = dm . getUserItemTimestamps ( user , item ) ; if ( time == null ) { out . println ( user + delimiter + item + delimiter + pref + delimiter + "-1" ) ; } else { for ( Long t : time ) { out . println ( user + delimiter + item + delimiter + pref + delimiter + t ) ; } } } } out . close ( ) ; } }
Method that saves a temporal data model to a file.

@param dm the data model
@param outfile file where the model will be saved
@param overwrite flag that indicates if the file should be overwritten
@param delimiter field delimiter
@param <U> type of users
@param <I> type of items
@throws FileNotFoundException when outfile cannot be used.
@throws UnsupportedEncodingException when the requested encoding (UTF-8)
is not available.