List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:Main.java
public static void main(String[] args) { char[] c = { 'a', 'b', 'c' }; PrintStream ps = new PrintStream(System.out); // print an array and change line ps.println(c); ps.print("from java2s.com"); // flush the stream ps.flush();//from w w w . j a v a2 s . c o m }
From source file:Main.java
public static void main(String[] args) { char c = 'a'; PrintStream ps = new PrintStream(System.out); // print a char and change line ps.println(c); ps.println('b'); ps.print("from java2s.com"); // flush the stream ps.flush();//from w w w. j a v a2s . com }
From source file:Main.java
public static void main(String[] args) { Object c = 15;/* w w w.ja v a 2 s .c o m*/ PrintStream ps = new PrintStream(System.out); // print an object and change line ps.println(c); ps.print("from java2s.com"); // flush the stream ps.flush(); }
From source file:Main.java
public static void main(String[] args) { int c = 123;/*www.j a va 2 s. c o m*/ PrintStream ps = new PrintStream(System.out); // print an integer and change line ps.println(c); ps.print("from java2s.com"); // flush the stream ps.flush(); }
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 . ja v a2 s. co m 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;// ww w . ja va2 s. 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) { long c = 1234567890L; try {/*from w ww .j a v a 2s .c o m*/ PrintStream ps = new PrintStream(System.out); // print a long and change line ps.println(c); ps.print("from java2s.com"); // flush the stream ps.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
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 ww . j a v a 2s .com*/ PrintStream pstream = new PrintStream(sock.getOutputStream()); for (int i = 100; i >= 0; i--) { pstream.println(i); } pstream.close(); sock.close(); }
From source file:TestDumpRecord.java
public static void main(String[] args) throws NITFException { List<String> argList = Arrays.asList(args); List<File> files = new LinkedList<File>(); for (String arg : argList) { File f = new File(arg); if (f.isDirectory()) { File[] dirFiles = f.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { String ext = FilenameUtils.getExtension(name).toLowerCase(); return ext.matches("nitf|nsf|ntf"); }/*w w w . j a va 2 s . com*/ }); files.addAll(Arrays.asList(dirFiles)); } else files.add(f); } Reader reader = new Reader(); for (File file : files) { PrintStream out = System.out; out.println("=== " + file.getAbsolutePath() + " ==="); IOHandle handle = new IOHandle(file.getAbsolutePath()); Record record = reader.read(handle); dumpRecord(record, reader, out); handle.close(); record.destruct(); // tells the memory manager to decrement the ref // count } }
From source file:common.ReverseWordsCount.java
public static void main(String[] args) throws IOException { List<String> readLines = FileUtils.readLines(new File("G:\\\\LTNMT\\LTNMT\\sougou\\sougou2500.txt")); Map<String, Integer> words = new HashMap<>(); for (String line : readLines) { String[] split = line.split(" "); for (String wprd : split) { Integer get = words.get(wprd); if (get == null) { words.put(wprd, 1);/*from w w w . j a v a2s .c om*/ } else { words.put(wprd, get + 1); } } } Set<Map.Entry<String, Integer>> entrySet = words.entrySet(); List<Map.Entry<String, Integer>> reverseLists = new ArrayList<>(entrySet); Collections.sort(reverseLists, new Comparator<Map.Entry<String, Integer>>() { @Override public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) { return o2.getValue().compareTo(o1.getValue()); } }); PrintStream ps = new PrintStream("c:/reverseWords.txt"); for (Map.Entry<String, Integer> teEntry : reverseLists) { ps.println(teEntry.getKey() + " " + teEntry.getValue()); } ps.close(); }