List of usage examples for java.io BufferedReader BufferedReader
public BufferedReader(Reader in)
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); int value = 0; while ((value = br.read()) != -1) { char c = (char) value; System.out.println(c);//w w w. j a v a 2 s .co m } }
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;/*w w w . ja v a 2s . com*/ while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); }
From source file:Main.java
public static void main(String[] arguments) throws Exception { StringBuffer output = new StringBuffer(); FileReader file = new FileReader("a.htm"); BufferedReader buff = new BufferedReader(file); boolean eof = false; while (!eof) { String line = buff.readLine(); if (line == null) eof = true;/*from w ww .jav a2s . com*/ else output.append(line + "\n"); } buff.close(); String page = output.toString(); Pattern pattern = Pattern.compile("<a.+href=\"(.+?)\""); Matcher matcher = pattern.matcher(page); while (matcher.find()) { System.out.println(matcher.group(1)); } }
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); boolean bool = false; bool = br.markSupported();/*from www . j ava 2 s. c om*/ System.out.println("Buffered reader supports mark : " + bool); }
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;// w w w .ja va2s.c o m 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 . j av a2 s .c om 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: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); char[] cbuf = new char[is.available()]; br.read(cbuf, 2, 10);//from w w w. jav a 2 s. c o m for (char c : cbuf) { if (c == (char) 0) { c = '*'; } // prints characters System.out.print(c); } }
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); System.out.println((char) br.read()); System.out.println((char) br.read()); br.mark(26);//from www. ja va 2 s.c om System.out.println("mark() invoked"); System.out.println((char) br.read()); System.out.println((char) br.read()); br.reset(); System.out.println("reset() invoked"); System.out.println((char) br.read()); System.out.println((char) br.read()); }
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 a2 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 ww w . ja va2 s . c o m*/ for (int i = 0; i < av.length; i++) try { v.process(new BufferedReader(new FileReader(av[i]))); } catch (FileNotFoundException e) { System.err.println(e); } }