MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.InputStream;
import java.net.Socket;
import java.util.Date;

public class MainClass {
    public static void main(String[] args) throws Exception {

        String hostname = "time.nist.gov";
        int port = 37;

        InputStream raw = null;
        Socket theSocket = new Socket(hostname, port);
        raw = theSocket.getInputStream();

        System.out.println(raw.read());

        raw.close();
    }

}