List of usage examples for java.io BufferedReader readLine
public String readLine() throws IOException
From source file:MainClass.java
public static void main(String[] args) throws Exception { Runtime r = Runtime.getRuntime(); String[] nargs = { "sh", "-c", "for i in 1 2 3; do echo $i; done" }; Process p = r.exec(nargs);//from w w w .j a v a 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:DateFormatFile.java
public static void main(String[] args) throws IOException { DateFormatFile df = new DateFormatFile(); BufferedReader is = new BufferedReader(new InputStreamReader(System.in)); String line;//from w w w .j ava 2 s.c o m while ((line = is.readLine()) != null) { df.process(line); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { File f = new File("C:\\test.txt"); FileReader fr = new FileReader(f); BufferedReader br = new BufferedReader(fr); StringBuffer sb = new StringBuffer(); String eachLine = br.readLine(); while (eachLine != null) { sb.append(eachLine);//ww w. j a va 2s . c om sb.append("\n"); eachLine = br.readLine(); } System.out.println(sb.toString()); }
From source file:Print.java
public static void main(String[] args) throws Exception { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL, "file:/tmp/marketing"); Context initCtx = new InitialContext(env); File f = (File) initCtx.lookup("reports/report1.txt"); if (f != null) { BufferedReader br = new BufferedReader(new FileReader(f)); String l = null;/*from www.j ava 2s .com*/ while ((l = br.readLine()) != null) System.out.println(l); } }
From source file:Main.java
public static void main(String args[]) throws Exception { FileReader fr = new FileReader(args[0]); BufferedReader br = new BufferedReader(fr); // Process lines from file String line;/*from ww w . j av a2 s.c om*/ while ((line = br.readLine()) != null) { char array[] = line.toCharArray(); System.out.print(array[0]); } }
From source file:Grep.java
public static void main(String args[]) throws Exception { String regex = ""; InputStream in = System.in; regex = args[0];//from w ww . j a va 2 s .c o m in = new BufferedInputStream(new FileInputStream(args[1])); Pattern p = null; p = Pattern.compile(regex); BufferedReader buff = new BufferedReader(new InputStreamReader(in)); String a; for (a = buff.readLine(); a != null; a = buff.readLine()) { Matcher m = p.matcher(a); if (m.find()) { System.out.println(a); } } }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new FileReader("ravi.txt")); while (true) { String line = br.readLine(); if (line == null) break; if (!UCODE_PATTERN.matcher(line).matches()) { System.err.println("Bad input: " + line); } else {/*from w w w . ja v a 2 s . co m*/ String hex = line.substring(2, 6); int number = Integer.parseInt(hex, 16); System.out.println(hex + " -> " + ((char) number)); } } }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com"); URLConnection conn = url.openConnection(); conn.setDoOutput(true);/*from w ww.j av a 2s. c o m*/ OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); writer.write("value=1&anotherValue=1"); writer.flush(); String line; BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((line = reader.readLine()) != null) { System.out.println(line); } writer.close(); reader.close(); }
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 w w w. j a v a 2s.c o m*/ while ((str = reader.readLine()) != null) { System.out.println(str); } }
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 ww. j av a 2 s .c o m while ((line = in.readLine()) != null) { System.out.println(line); } in.close(); }