Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.BufferedReader;
import java.io.FileReader;
import java.net.Socket;
import java.util.zip.GZIPOutputStream;

public class Main {
    public static void main(String[] args) throws Exception {
        Socket sock = new Socket(args[0], Integer.parseInt(args[1]));
        GZIPOutputStream zip = new GZIPOutputStream(sock.getOutputStream());
        String line;
        BufferedReader bis = new BufferedReader(new FileReader(args[2]));
        while (true) {
            line = bis.readLine();
            if (line == null)
                break;
            line = line + "\n";
            zip.write(line.getBytes(), 0, line.length());
        }
        zip.finish();
        zip.close();
        sock.close();
    }
}