/**
 * This class can take a variable number of parameters on the command
 * line. Program execution begins with the main() method. The class
 * constructor is not invoked unless an object of type 'Class1'
 * created in the main() method.{}
 */
package Project1;
import COM.meitca.concordia.*;
import java.util.*;
import java.net.*;
import java.io.*;
import Project1.Pause;

public class Class1 extends VirtAgent {
	
	private
		BufferedInputStream bis;
		BufferedOutputStream bos;
		URL url;
		URLConnection http;
		Pause p;

	public Class1(){
	}
	/**
		This method will be executed on remote server
	 */
	
	public void run()
	{	int i=1;
		Pause p = new Pause();
		//p.start();

		while(i-- > 0){
			try{
				getData();
				p.run();
			} catch (Exception e) {
				System.err.println(e.getMessage());
				e.printStackTrace();
			}
		}
		System.out.println("Tuto Finnito! / Class1.run()\n");

	}
	
	//This should fetch data from server
	public void getData()	{
		// TODO: This is only example, replace this code!
		//byte pom[]=new byte[1000];
		try{
			url=new URL("http://localhost/Sareno/riba/fish1.html");
			bis = new BufferedInputStream(url.openStream());
			http=url.openConnection();
			
			
			System.out.println("Dejan was here! / pisi\n");
			System.out.println((url.getContent()));
			int i=1, n;
			while ((http.getHeaderField(i)!=null)){
				//System.out.println(http.getHeaderFieldKey(i)+" "+ http.getHeaderField(i));	//prikazije elemente zaglavlja
				System.out.println("Last-Modified: "+ http.getHeaderField("Last-Modified"));	//prikazije elemente zaglavlja
				System.out.println("Last-Modified Date: "+ http.getHeaderFieldDate("Last-Modified", -1));	//prikazije elemente zaglavlja
				System.out.println("Last-Modified Date: "+ http.getLastModified());	//prikazije elemente zaglavlja
				i++;
			}

		} catch (Exception e) {
			System.err.println(e.getMessage());
			e.printStackTrace();
		}

	}
	

}
