Example usage for java.io BufferedReader close

List of usage examples for java.io BufferedReader close

Introduction

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

Prototype

public void close() throws IOException 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    InputStream is = new FileInputStream("c:/test.txt");

    InputStreamReader isr = new InputStreamReader(is);

    BufferedReader br = new BufferedReader(isr);

    br.close();

    // creates error
    br.read();/*from www.  j av  a 2  s. co  m*/

}

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  ww.  ja v a 2s  .  c o  m
    System.out.println(x);
    in.close();

}

From source file:MainClass.java

public static void main(String[] a) throws Exception {
    String fileName = "BigFile.txt";
    FileInputStream fis = new FileInputStream(fileName);
    JLabel filenameLabel = new JLabel(fileName, JLabel.RIGHT);
    Object message[] = { "Reading:", filenameLabel };
    ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, message, fis);
    InputStreamReader isr = new InputStreamReader(pmis);
    BufferedReader br = new BufferedReader(isr);
    String line;//  w ww.j a v a 2s  .  com
    while ((line = br.readLine()) != null) {
        System.out.println(line);
    }
    br.close();
}

From source file:Sequence.java

public static void main(String args[]) throws IOException {
    Vector v = new Vector(3);
    v.add(new FileInputStream("/etc/motd"));
    v.add(new FileInputStream("foo.bar"));
    v.add(new FileInputStream("/temp/john.txt"));
    Enumeration e = v.elements();
    SequenceInputStream sis = new SequenceInputStream(e);
    InputStreamReader isr = new InputStreamReader(sis);
    BufferedReader br = new BufferedReader(isr);
    String line;//from  w w w  .j  a  v a 2  s. c om
    while ((line = br.readLine()) != null) {
        System.out.println(line);
    }
    br.close();
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Vector v = new Vector(3);
    v.add(new FileInputStream("/a/b"));
    v.add(new FileInputStream("yourfile.bar"));
    v.add(new FileInputStream("/yourfile.txt"));

    Enumeration e = v.elements();
    SequenceInputStream sis = new SequenceInputStream(e);
    InputStreamReader isr = new InputStreamReader(sis);
    BufferedReader br = new BufferedReader(isr);
    String line;/*from www  .j  a v  a  2 s . c o  m*/
    while ((line = br.readLine()) != null) {
        System.out.println(line);
    }
    br.close();
}

From source file:Main.java

public static void main(String argv[]) throws Exception {
    String line;/*from  w w  w  . ja  v  a2 s . com*/
    Process p = Runtime.getRuntime().exec("psql -U username -d dbname -h serverhost -f scripfile.sql");
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
        System.out.println(line);
    }
    input.close();
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {
    // 1. Reading input by lines:
    BufferedReader in = new BufferedReader(new FileReader("IOStreamDemo.java"));
    String s, s2 = new String();
    while ((s = in.readLine()) != null)
        s2 += s + "\n";
    in.close();

}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    System.setProperty("javax.net.ssl.trustStore", "clienttrust");

    SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault();
    Socket s = ssf.createSocket("127.0.0.1", 5432);

    SSLSession session = ((SSLSocket) s).getSession();
    Certificate[] cchain = session.getPeerCertificates();
    System.out.println("The Certificates used by peer");
    for (int i = 0; i < cchain.length; i++) {
        System.out.println(((X509Certificate) cchain[i]).getSubjectDN());
    }// ww w. j av  a  2  s.  c om
    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());

    BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    String x = in.readLine();
    System.out.println(x);
    in.close();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String srcFile = "test.txt";
    BufferedReader br = new BufferedReader(new FileReader(srcFile));
    String text = null;// w  w w .j av a 2s.  c o  m

    while ((text = br.readLine()) != null) {
        System.out.println(text);
    }
    br.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new FileReader("filename.txt"));

    String line = null;/*from   w w  w  . ja va 2  s  .  com*/
    while ((line = br.readLine()) != null) {
        System.out.println(line);
    }
    br.close();
}