Example usage for java.io InputStreamReader InputStreamReader

List of usage examples for java.io InputStreamReader InputStreamReader

Introduction

In this page you can find the example usage for java.io InputStreamReader InputStreamReader.

Prototype

public InputStreamReader(InputStream in) 

Source Link

Document

Creates an InputStreamReader that uses the default charset.

Usage

From source file:Main.java

public static void main(String args[]) throws IOException {

    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(args);
    InputStream is = process.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;//  w w  w  .  ja v  a 2 s.  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:MainClass.java

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

    SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    ServerSocket ss = ssf.createServerSocket(PORT);
    Socket s = ss.accept();/*w ww . jav  a  2 s.  c o  m*/
    BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    String line = null;
    while (((line = in.readLine()) != null)) {
        System.out.println(line);
    }
    in.close();
    s.close();
}

From source file:ScriptExecutionReaderDemo.java

public static void main(String[] args) throws Exception {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine jsEengine = manager.getEngineByExtension("js");
    Reader reader = new InputStreamReader(new FileInputStream("yourJavaScript.js"));
    jsEengine.eval(reader);/* w ww  .  j  a  va2 s  .  co  m*/
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    URL url = new URL(args[0]);
    Reader reader = new InputStreamReader((InputStream) url.getContent());
    System.out.println("<HTML><HEAD><TITLE>Links for " + args[0] + "</TITLE>");
    System.out.println("<BASE HREF=\"" + args[0] + "\"></HEAD>");
    System.out.println("<BODY>");
    new ParserDelegator().parse(reader, new LinkPage(), false);
    System.out.println("</BODY></HTML>");
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    URL url = new URL(args[0]);
    Reader reader = new InputStreamReader((InputStream) url.getContent());
    new ParserDelegator().parse(reader, new HTMLParse(), false);
}

From source file:ExecShellArgs.java

public static void main(String[] args) throws IOException {
    Runtime r = Runtime.getRuntime();
    String[] nargs = { "sh", "-c", "for i in 1 2 3; do echo $i; done" };
    Process p = r.exec(nargs);/* w w w  . j ava  2 s.  c  o  m*/
    BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = is.readLine()) != null)
        System.out.println(line);
}

From source file:Main.java

License:asdf

public static void main(String[] arges) throws Exception {

    InetAddress addr = InetAddress.getByName(null);
    Socket sk = new Socket(addr, 8888);
    BufferedReader in = new BufferedReader(new InputStreamReader(sk.getInputStream()));
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(sk.getOutputStream())), true);
    out.println("asdf");
    System.out.println(in.readLine());
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    ServerSocket serverSocket = new ServerSocket(8080);
    Socket socket = serverSocket.accept();

    InputStream inStream = socket.getInputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
    String str = null;/*from   ww  w .  ja v a 2s. c  o  m*/
    while ((str = reader.readLine()) != null) {
        System.out.println(str);
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    DatagramSocket udpSocket = new DatagramSocket();
    String msg = null;//from   w w w. java 2  s . com
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Please enter a  message  (Bye  to quit):");
    while ((msg = br.readLine()) != null) {
        if (msg.equalsIgnoreCase("bye")) {
            break;
        }
        DatagramPacket packet = Main.getPacket(msg);
        udpSocket.send(packet);
        udpSocket.receive(packet);
        displayPacketDetails(packet);
        System.out.print("Please enter a  message  (Bye  to quit):");
    }
    udpSocket.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Authenticator.setDefault(new MyAuthenticator());
    URL url = new URL("http://hostname:80/index.html");

    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String str;// www  .  j  a  va2  s  .c om
    while ((str = in.readLine()) != null) {
        System.out.println(str);
    }
    in.close();
}