/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package serverwiththread;

import java.io.*;
import java.net.*;

/**
 *
 * @author rafal
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            //InetAddress address = InetAddress.getByName("http://remoto.pl");
            String text = "GET  /  HTTP/1.0\r\n\r\n";
            Socket socket = new Socket("www.remoto.pl", 80);
            //socket.
           
            OutputStream stream = (OutputStream) socket.getOutputStream();
            stream.write(text.getBytes(),0, text.length());
            //stream.writ
            InputStream streaminput = (InputStream) socket.getInputStream();
            File file = new File("remoto.html");
            FileOutputStream osi = new FileOutputStream(file);
            for (int i =0; i < 10000; i++) {
           //System.out.print((char)streaminput.read());
               
               // FileOutputStream osf = new FileOutputStream(file);
                byte[] table = new byte[10];
                streaminput.read(table, 0, 10);


                osi.write(table);
            }
        } catch(Exception e) {
        e.printStackTrace();
        }

    }

}
