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 { SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); ServerSocket ss = ssf.createServerSocket(PORT); Socket s = ss.accept();/*from w w w. j av a 2s. co 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:CollateApp.java
public static void main(String args[]) { if (args.length != 1) { System.out.println("Usage: java CollateApp file"); System.exit(0);/*from w w w . j a v a 2 s . co m*/ } Locale defaultLocale = Locale.getDefault(); RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(defaultLocale); Vector keyVector = new Vector(); try { BufferedReader in = new BufferedReader(new FileReader(args[0])); String line; while ((line = in.readLine()) != null) keyVector.addElement(collator.getCollationKey(line)); in.close(); } catch (Exception ex) { System.out.println(ex); System.exit(0); } CollationKey keys[] = new CollationKey[keyVector.size()]; for (int i = 0; i < keys.length; ++i) keys[i] = (CollationKey) keyVector.elementAt(i); }
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;/* ww w . j a v a2 s . co m*/ while ((str = in.readLine()) != null) { System.out.println(str); } in.close(); }
From source file:Main.java
public static void main(String args[]) throws IOException { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the char:"); String str = buff.readLine(); for (int i = 0; i < str.length(); ++i) { char c = str.charAt(i); int j = (int) c; System.out.println("ASCII OF " + c + " = " + j + "."); }/*from w w w . j ava 2 s . c o m*/ }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();//from ww w . j a v a 2 s . c om PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); BufferedReader reader = new BufferedReader(new FileReader("a.txt")); String line; while ((line = reader.readLine()) != null) { ct.addText(new Phrase(line + "\n")); } reader.close(); ct.setSimpleColumn(36, 36, PageSize.A4.width() - 36, PageSize.A4.height() - 36, 18, Element.ALIGN_JUSTIFIED); int status = ColumnText.START_COLUMN; while (ColumnText.hasMoreText(status)) { status = ct.go(); ct.setYLine(PageSize.A4.height() - 36); document.newPage(); } document.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { Process process = Runtime.getRuntime().exec("ls -al"); process.waitFor();// w ww.j a v a 2 s. 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: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 . j a v a2 s . com*/ while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); }
From source file:CollateApp.java
public static void main(String args[]) { if (args.length != 1) { System.out.println("Usage: java CollateApp file"); System.exit(0);// ww w .j a v a 2 s. c o m } Locale defaultLocale = Locale.getDefault(); RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(defaultLocale); Vector<Object> keyVector = new Vector<Object>(); try { BufferedReader in = new BufferedReader(new FileReader(args[0])); String line; while ((line = in.readLine()) != null) keyVector.addElement(collator.getCollationKey(line)); in.close(); } catch (Exception ex) { System.out.println(ex); System.exit(0); } CollationKey keys[] = new CollationKey[keyVector.size()]; for (int i = 0; i < keys.length; ++i) keys[i] = (CollationKey) keyVector.elementAt(i); }
From source file:com.game.GameLauncherApplication.java
public static void main(String[] args) throws Exception { // System.exit is common for Batch applications since the exit code can be used to // drive a workflow // System.exit(SpringApplication.exit(SpringApplication.run( // SampleBatchApplication.class, args))); String s = "Y"; while ("Y".equalsIgnoreCase(s.trim())) { ticTacToeGame.startGame();/*from w w w .j av a 2 s . co m*/ System.out.println(" Do you want to play more to Play more enter Y "); BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); s = BR.readLine(); if (s != null && !s.isEmpty()) { s = s.trim(); } } }
From source file:web.restful.ClientTest.java
public static void main(String[] args) throws ClientProtocolException, IOException { HttpClient client = new DefaultHttpClient(); HttpPut put = new HttpPut("http://localhost:8080/ss16-lab-web/resources/outliers/session"); put.setEntity(new StringEntity("upenkwbq"));// session ID client.execute(put);/*from www. ja va2 s.co m*/ put.releaseConnection(); put = new HttpPut("http://localhost:8080/ss16-lab-web/resources/outliers/bucket"); put.setEntity(new StringEntity("Level1/Level1_Bin_1.txt")); // bucket name client.execute(put); put.releaseConnection(); put = new HttpPut("http://localhost:8080/ss16-lab-web/resources/outliers/method"); put.setEntity(new StringEntity("chauvenet")); // method name client.execute(put); put.releaseConnection(); HttpGet get = new HttpGet("http://localhost:8080/ss16-lab-web/resources/outliers"); HttpResponse response = client.execute(get); HttpEntity en = response.getEntity(); InputStreamReader i = new InputStreamReader(en.getContent()); BufferedReader rd = new BufferedReader(i); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); } }