List of usage examples for java.io InputStreamReader InputStreamReader
public InputStreamReader(InputStream in)
From source file:MainClass.java
public static void main(String[] args) throws Exception { System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); URL url = new URL("https://www.verisign.com/"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line;/* w w w . j a v a 2 s .com*/ while ((line = in.readLine()) != null) { System.out.println(line); } in.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("https://www.server.com"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine;//from w w w .ja v a 2 s. c o m while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); }
From source file:Main.java
public static void main(String args[]) throws IOException { Process process = new ProcessBuilder(args).start(); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line;//from w w w. j a v a2s. c o m System.out.printf("Output of running %s is:", Arrays.toString(args)); while ((line = br.readLine()) != null) { System.out.println(line); } }
From source file:Main.java
public static void main(String[] args) throws IOException { ExecutorService service = Executors.newFixedThreadPool(4); BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); String line;/*www . java 2 s .com*/ while ((line = buffer.readLine()) != null) { service.execute(new Worker(line)); } }
From source file:Main.java
public static void main(String[] args) throws Exception { Process process = Runtime.getRuntime().exec("ls -al"); process.waitFor();//w w w .jav a2s . c o m int exitValue = process.exitValue(); System.out.println("exitValue = " + exitValue); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { URL u = new URL("http://www.java2s.com"); InputStream in = u.openStream(); in = new BufferedInputStream(in); Reader r = new InputStreamReader(in); int c;// w w w .j av a2 s .c o m while ((c = r.read()) != -1) { System.out.print((char) c); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault(); Socket s = ssf.createSocket("127.0.0.1", 5432); BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); String x = in.readLine();/*from w w w. java 2 s .c om*/ System.out.println(x); in.close(); }
From source file:Vis.java
public static void main(String[] av) { Vis v = new Vis(); if (av.length == 0) v.process(new BufferedReader(new InputStreamReader(System.in))); else/*from www .j a v a2s .c om*/ for (int i = 0; i < av.length; i++) try { v.process(new BufferedReader(new FileReader(av[i]))); } catch (FileNotFoundException e) { System.err.println(e); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { int port = 2000; ServerSocket srv = new ServerSocket(port); // Wait for connection from client. Socket socket = srv.accept(); BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream())); String str;//from w w w. j av a2 s .c om while ((str = rd.readLine()) != null) { System.out.println(str); } rd.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("javascript"); engine.eval(new InputStreamReader(Main.class.getResourceAsStream("scripting.js"))); List<String> list1 = (List<String>) engine.get("list1"); if (list1 != null) { for (String s : (List<String>) list1) { System.out.println(s); }/*from w w w. ja v a2 s . c om*/ } Invocable engineInv = (Invocable) engine; Object obj = engine.get("listObject"); Object list2 = engineInv.invokeMethod(obj, "getList2"); if (list2 != null) { for (String s : (List<String>) list2) { System.out.println(s); } } }