Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaandrotest;
- import java.io.*;
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.util.Date;
- /**
- *
- * @author bennet.hentschel
- */
- public class Server {
- private static ServerSocket server;
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws IOException {
- server = new ServerSocket(80);
- Socket client = null;
- try {
- client = server.accept();
- System.out.println(client.toString());
- OutputStream outputStream = client.getOutputStream();
- ObjectOutputStream s = new ObjectOutputStream(outputStream);
- s.writeObject(new Date(11333377));
- System.out.println("wrote Object");
- s.flush();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (client != null) {
- try {
- client.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- public static void send(Object a) {
- try {
- FileOutputStream out = new FileOutputStream("theTime");
- ObjectOutputStream s = new ObjectOutputStream(out);
- s.writeObject(a);
- s.flush();
- } catch (Exception ex) {
- System.out.println(ex.toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment