List of usage examples for java.io PrintStream close
public void close()
From source file:MainClass.java
public static void main(String args[]) throws Exception { SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); ServerSocket ss = ssf.createServerSocket(5432); while (true) { Socket s = ss.accept();/*from w w w . j a v a 2 s . co m*/ PrintStream out = new PrintStream(s.getOutputStream()); out.println("Hi"); out.close(); s.close(); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { System.setProperty("javax.net.ssl.keyStore", "mykeystore"); System.setProperty("javax.net.ssl.keyStorePassword", "wshr.ut"); SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); ServerSocket ss = ssf.createServerSocket(5432); while (true) { Socket s = ss.accept();/* w ww . ja v a 2 s .c o m*/ PrintStream out = new PrintStream(s.getOutputStream()); out.println("Hi"); out.close(); s.close(); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { System.setProperty("javax.net.ssl.keyStore", "lfkeystore2"); System.setProperty("javax.net.ssl.keyStorePassword", "wshr.ut"); SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); ServerSocket ss = ssf.createServerSocket(5432); while (true) { Socket s = ss.accept();/*from w ww. j a va 2s. c om*/ SSLSession session = ((SSLSocket) s).getSession(); Certificate[] cchain2 = session.getLocalCertificates(); for (int i = 0; i < cchain2.length; i++) { System.out.println(((X509Certificate) cchain2[i]).getSubjectDN()); } System.out.println("Peer host is " + session.getPeerHost()); System.out.println("Cipher is " + session.getCipherSuite()); System.out.println("Protocol is " + session.getProtocol()); System.out.println("ID is " + new BigInteger(session.getId())); System.out.println("Session created in " + session.getCreationTime()); System.out.println("Session accessed in " + session.getLastAccessedTime()); PrintStream out = new PrintStream(s.getOutputStream()); out.println("Hi"); out.close(); s.close(); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { SSLContext context;//from w w w .ja v a 2s. c o m KeyManagerFactory kmf; KeyStore ks; char[] storepass = "newpass".toCharArray(); char[] keypass = "wshr.ut".toCharArray(); String storename = "newstore"; context = SSLContext.getInstance("TLS"); kmf = KeyManagerFactory.getInstance("SunX509"); FileInputStream fin = new FileInputStream(storename); ks = KeyStore.getInstance("JKS"); ks.load(fin, storepass); kmf.init(ks, keypass); context.init(kmf.getKeyManagers(), null, null); SSLServerSocketFactory ssf = context.getServerSocketFactory(); ServerSocket ss = ssf.createServerSocket(5432); while (true) { Socket s = ss.accept(); PrintStream out = new PrintStream(s.getOutputStream()); out.println("Hi"); out.close(); s.close(); } }
From source file:Main.java
public static void main(String args[]) throws Exception { ServerSocket ssock = new ServerSocket(1234); Socket sock = ssock.accept(); ssock.close();/*from w w w. ja v a 2 s .c o m*/ PrintStream pstream = new PrintStream(sock.getOutputStream()); for (int i = 100; i >= 0; i--) { pstream.println(i); } pstream.close(); sock.close(); }
From source file:dataflow.examples.DockerClientExample.java
public static void main(String[] args) throws IOException, DockerException, InterruptedException { String localTempDir = createLocalTempDir(); String dockerAddress = "unix:///var/run/docker.sock"; String dockerImage = "ubuntu:latest"; DockerClient dockerClient = new DefaultDockerClient(dockerAddress); String localInput = FilenameUtils.concat(localTempDir, "file_on_host.txt"); PrintStream stream = new PrintStream(localInput); stream.append("\nHello from the host machine.\n"); stream.close(); // Run a simple command in the container to demonstrate we can read the // file mounted from the host. ArrayList<String> command = new ArrayList<String>(); command.add("cat"); command.add("/mounted/file_on_host.txt"); DockerProcessBuilder builder = new DockerProcessBuilder(command, dockerClient); builder.addVolumeMapping(localTempDir, "/mounted"); builder.setImage(dockerImage);/*from w ww . j av a2s . c om*/ // Start and run the container. builder.start(); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte c = 70;/*from w w w .j av a2 s .c o m*/ PrintStream ps = new PrintStream(new File("c:/text.txt"), "ASCII"); // write byte c which is character F in ASCII ps.write(c); // flush the stream ps.flush(); ps.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com. "; PrintStream ps = new PrintStream(System.out); // append our strings ps.append(s);//from w w w. ja v a 2 s . c om ps.append("This is an example."); // print the result ps.flush(); ps.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com."; // create a new PrintStream PrintStream ps = new PrintStream(System.out); // print a string ps.println(s);// w ww.j ava 2s . c om // check for errors and print ps.print(ps.checkError()); ps.flush(); ps.close(); }
From source file:Main.java
public static void main(String[] args) { CharSequence csq = "from java2s.com"; PrintStream ps = new PrintStream(System.out); // append our character sequences ps.append(csq, 6, 11);/* ww w. j a va 2 s. c om*/ ps.append(csq, 0, 5); // print the result ps.flush(); ps.close(); }