// Path: baggle-datagrams/src/inouire/baggle/types/IllegalDatagramException.java
// public class IllegalDatagramException extends Exception{
// 
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import inouire.baggle.types.IllegalDatagramException;
import inouire.basics.SimpleLog;
     * Load the server list from file
     * @param nb_days the max age in days for validity of an entry. invalid entry is not loaded
     */
    public void loadList(int nb_days){
        
        long timestamp_min = System.currentTimeMillis()-(86400000*nb_days);
        
        FileInputStream in;
        try {
            in = new FileInputStream(LIST_FILE);
        } catch (FileNotFoundException ex) {
            SimpleLog.logger.warn("Impossible to open file at "+LIST_FILE.getAbsolutePath());
            return;
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        try{
            String line="";
            String[] content;
            ConfigKey key;
            String value;

            while((line = reader.readLine()) != null ){
                content = line.split("\\|");
                try{
                    ServerEntry entry = new ServerEntry(content);
                    if(entry.timestamp > timestamp_min){
                        cached_servers.add(entry);
                    }else{
                        SimpleLog.logger.debug("Not adding server entry, too old: "+line);
                    }
// Path: baggle-datagrams/src/inouire/baggle/types/IllegalDatagramException.java
// public class IllegalDatagramException extends Exception{
// 
// }


// Path: baggle-client/src/inouire/baggle/client/CachedServersList.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import inouire.baggle.types.IllegalDatagramException;
import inouire.basics.SimpleLog;

     * Load the server list from file
     * @param nb_days the max age in days for validity of an entry. invalid entry is not loaded
     */
    public void loadList(int nb_days){
        
        long timestamp_min = System.currentTimeMillis()-(86400000*nb_days);
        
        FileInputStream in;
        try {
            in = new FileInputStream(LIST_FILE);
        } catch (FileNotFoundException ex) {
            SimpleLog.logger.warn("Impossible to open file at "+LIST_FILE.getAbsolutePath());
            return;
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        try{
            String line="";
            String[] content;
            ConfigKey key;
            String value;

            while((line = reader.readLine()) != null ){
                content = line.split("\\|");
                try{
                    ServerEntry entry = new ServerEntry(content);
                    if(entry.timestamp > timestamp_min){
                        cached_servers.add(entry);
                    }else{
                        SimpleLog.logger.debug("Not adding server entry, too old: "+line);
                    }
                }catch(IllegalDatagramException ide){