package tests;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;


public class testLogged {

	public static boolean testLog(File file) {
		FileReader fr;
		
		try {
			fr = new FileReader(file);
			String str = "";
			int i = 0;
			while((i = fr.read()) != -1)
				str += (char)i;
			
			//System.out.println(str);
			if (str != ""){
				int a = str.indexOf(" ");
				String s = str.substring(a+1);
				Long j =	Long.parseLong(s);
				long k = (long) j;
				Date date = new Date();
				Long dat = date.getTime();
				long idate = dat.longValue();
				
				//System.out.println(k);
				//System.out.println(idate);
				//long l = idate-k;
				//System.out.println(l);
				
				if ((k+30000)>=idate){
					return true;
				}
				else{
					file.delete();
					return false;
				}
			}
			else {
				return false;
			}
			
		} catch (FileNotFoundException e) {
			return false;
		} catch (IOException e) {
			return false;
		}
	}
	
}
