import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.Socket;

class TCPClientSend9 {

  public static void main(String argv[]) throws Exception {
    String fileName = "alice.txt";
    String host = (argv.length > 0) ? argv[0] : "localhost";
    Socket clientSocket = new Socket(host, 6789);
    System.out.println("Connected...");
    OutputStream outToServer = clientSocket.getOutputStream();

    File f = new File(fileName);
    FileInputStream fin = new FileInputStream(f);
    // FileInputStream bietet die Gesamtzahl lesbarer Bytes
    System.out.println("Total file size to read (in bytes) : " + fin.available());

    fin.transferTo(outToServer);
    System.out.println("Ready...");
    fin.close();
    clientSocket.close();
  }
} 
