<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FFile_Input_Output%2FBufferedReader</id>
		<title>Java/File Input Output/BufferedReader - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FFile_Input_Output%2FBufferedReader"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/File_Input_Output/BufferedReader&amp;action=history"/>
		<updated>2026-04-21T18:45:54Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/File_Input_Output/BufferedReader&amp;diff=6253&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/File_Input_Output/BufferedReader&amp;diff=6253&amp;oldid=prev"/>
				<updated>2010-06-01T06:05:12Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:05, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/File_Input_Output/BufferedReader&amp;diff=6252&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/File_Input_Output/BufferedReader&amp;diff=6252&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== A simple FilterReader that strips HTML tags out of a stream of characters ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2004 David Flanagan.  All rights reserved.&lt;br /&gt;
 * This code is from the book Java Examples in a Nutshell, 3nd Edition.&lt;br /&gt;
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.&lt;br /&gt;
 * You may study, use, and modify it for any non-commercial purpose,&lt;br /&gt;
 * including teaching and use in open-source projects.&lt;br /&gt;
 * You may distribute it non-commercially as long as you retain this notice.&lt;br /&gt;
 * For a commercial use license, or to purchase the book, &lt;br /&gt;
 * please visit http://www.davidflanagan.ru/javaexamples3.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.FilterReader;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.Reader;&lt;br /&gt;
/**&lt;br /&gt;
 * A simple FilterReader that strips HTML tags (or anything between pairs of&lt;br /&gt;
 * angle brackets) out of a stream of characters.&lt;br /&gt;
 */&lt;br /&gt;
public class RemoveHTMLReader extends FilterReader {&lt;br /&gt;
  /** A trivial constructor. Just initialize our superclass */&lt;br /&gt;
  public RemoveHTMLReader(Reader in) {&lt;br /&gt;
    super(in);&lt;br /&gt;
  }&lt;br /&gt;
  boolean intag = false; // Used to remember whether we are &amp;quot;inside&amp;quot; a tag&lt;br /&gt;
  /**&lt;br /&gt;
   * This is the implementation of the no-op read() method of FilterReader. It&lt;br /&gt;
   * calls in.read() to get a buffer full of characters, then strips out the&lt;br /&gt;
   * HTML tags. (in is a protected field of the superclass).&lt;br /&gt;
   */&lt;br /&gt;
  public int read(char[] buf, int from, int len) throws IOException {&lt;br /&gt;
    int numchars = 0; // how many characters have been read&lt;br /&gt;
    // Loop, because we might read a bunch of characters, then strip them&lt;br /&gt;
    // all out, leaving us with zero characters to return.&lt;br /&gt;
    while (numchars == 0) {&lt;br /&gt;
      numchars = in.read(buf, from, len); // Read characters&lt;br /&gt;
      if (numchars == -1)&lt;br /&gt;
        return -1; // Check for EOF and handle it.&lt;br /&gt;
      // Loop through the characters we read, stripping out HTML tags.&lt;br /&gt;
      // Characters not in tags are copied over previous tags&lt;br /&gt;
      int last = from; // Index of last non-HTML char&lt;br /&gt;
      for (int i = from; i &amp;lt; from + numchars; i++) {&lt;br /&gt;
        if (!intag) { // If not in an HTML tag&lt;br /&gt;
          if (buf[i] == &amp;quot;&amp;lt;&amp;quot;)&lt;br /&gt;
            intag = true; // check for tag start&lt;br /&gt;
          else&lt;br /&gt;
            buf[last++] = buf[i]; // and copy the character&lt;br /&gt;
        } else if (buf[i] == &amp;quot;&amp;gt;&amp;quot;)&lt;br /&gt;
          intag = false; // check for end of tag&lt;br /&gt;
      }&lt;br /&gt;
      numchars = last - from; // Figure out how many characters remain&lt;br /&gt;
    } // And if it is more than zero characters&lt;br /&gt;
    return numchars; // Then return that number.&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * This is another no-op read() method we have to implement. We implement it&lt;br /&gt;
   * in terms of the method above. Our superclass implements the remaining&lt;br /&gt;
   * read() methods in terms of these two.&lt;br /&gt;
   */&lt;br /&gt;
  public int read() throws IOException {&lt;br /&gt;
    char[] buf = new char[1];&lt;br /&gt;
    int result = read(buf, 0, 1);&lt;br /&gt;
    if (result == -1)&lt;br /&gt;
      return -1;&lt;br /&gt;
    else&lt;br /&gt;
      return (int) buf[0];&lt;br /&gt;
  }&lt;br /&gt;
  /** The test program: read a text file, strip HTML, print to console */&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    try {&lt;br /&gt;
      if (args.length != 1)&lt;br /&gt;
        throw new IllegalArgumentException(&amp;quot;Wrong number of args&amp;quot;);&lt;br /&gt;
      // Create a stream to read from the file and strip tags from it&lt;br /&gt;
      BufferedReader in = new BufferedReader(new RemoveHTMLReader(new FileReader(args[0])));&lt;br /&gt;
      // Read line by line, printing lines to the console&lt;br /&gt;
      String line;&lt;br /&gt;
      while ((line = in.readLine()) != null)&lt;br /&gt;
        System.out.println(line);&lt;br /&gt;
      in.close(); // Close the stream.&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      System.err.println(e);&lt;br /&gt;
      System.err.println(&amp;quot;Usage: java RemoveHTMLReader$Test&amp;quot; + &amp;quot; &amp;lt;filename&amp;gt;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A standalone program that reads a list of classes and builds a database of packages, classes, and class fields and methods ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 2004 David Flanagan.  All rights reserved.&lt;br /&gt;
 * This code is from the book Java Examples in a Nutshell, 3nd Edition.&lt;br /&gt;
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.&lt;br /&gt;
 * You may study, use, and modify it for any non-commercial purpose,&lt;br /&gt;
 * including teaching and use in open-source projects.&lt;br /&gt;
 * You may distribute it non-commercially as long as you retain this notice.&lt;br /&gt;
 * For a commercial use license, or to purchase the book, &lt;br /&gt;
 * please visit http://www.davidflanagan.ru/javaexamples3.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.lang.reflect.Field;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Modifier;&lt;br /&gt;
import java.sql.Connection;&lt;br /&gt;
import java.sql.DriverManager;&lt;br /&gt;
import java.sql.PreparedStatement;&lt;br /&gt;
import java.sql.SQLException;&lt;br /&gt;
import java.sql.Statement;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.Properties;&lt;br /&gt;
/**&lt;br /&gt;
 * This class is a standalone program that reads a list of classes and builds a&lt;br /&gt;
 * database of packages, classes, and class fields and methods.&lt;br /&gt;
 */&lt;br /&gt;
public class MakeAPIDB {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Connection c = null; // The connection to the database&lt;br /&gt;
    try {&lt;br /&gt;
      // Read the classes to index from a file specified by args[0]&lt;br /&gt;
      ArrayList classnames = new ArrayList();&lt;br /&gt;
      BufferedReader in = new BufferedReader(new FileReader(args[0]));&lt;br /&gt;
      String name;&lt;br /&gt;
      while ((name = in.readLine()) != null)&lt;br /&gt;
        classnames.add(name);&lt;br /&gt;
      // Now determine the values needed to set up the database&lt;br /&gt;
      // connection The program attempts to read a property file named&lt;br /&gt;
      // &amp;quot;APIDB.props&amp;quot;, or optionally specified by args[1]. This&lt;br /&gt;
      // property file (if any) may contain &amp;quot;driver&amp;quot;, &amp;quot;database&amp;quot;, &amp;quot;user&amp;quot;,&lt;br /&gt;
      // and &amp;quot;password&amp;quot; properties that specify the necessary values for&lt;br /&gt;
      // connecting to the db. If the properties file does not exist, or&lt;br /&gt;
      // does not contain the named properties, defaults will be used.&lt;br /&gt;
      Properties p = new Properties(); // Empty properties&lt;br /&gt;
      try {&lt;br /&gt;
        p.load(new FileInputStream(args[1])); // Try to load properties&lt;br /&gt;
      } catch (Exception e1) {&lt;br /&gt;
        try {&lt;br /&gt;
          p.load(new FileInputStream(&amp;quot;APIDB.props&amp;quot;));&lt;br /&gt;
        } catch (Exception e2) {&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      // Read values from Properties file&lt;br /&gt;
      String driver = p.getProperty(&amp;quot;driver&amp;quot;);&lt;br /&gt;
      String database = p.getProperty(&amp;quot;database&amp;quot;);&lt;br /&gt;
      String user = p.getProperty(&amp;quot;user&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
      String password = p.getProperty(&amp;quot;password&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
      // The driver and database properties are mandatory&lt;br /&gt;
      if (driver == null)&lt;br /&gt;
        throw new IllegalArgumentException(&amp;quot;No driver specified!&amp;quot;);&lt;br /&gt;
      if (database == null)&lt;br /&gt;
        throw new IllegalArgumentException(&amp;quot;No database specified!&amp;quot;);&lt;br /&gt;
      // Load the driver. It registers itself with DriverManager.&lt;br /&gt;
      Class.forName(driver);&lt;br /&gt;
      // And set up a connection to the specified database&lt;br /&gt;
      c = DriverManager.getConnection(database, user, password);&lt;br /&gt;
      // Create three new tables for our data&lt;br /&gt;
      // The package table contains a package id and a package name.&lt;br /&gt;
      // The class table contains a class id, a package id, and a name.&lt;br /&gt;
      // The member table contains a class id, a member name, and an bit&lt;br /&gt;
      // that indicates whether the class member is a field or a method.&lt;br /&gt;
      Statement s = c.createStatement();&lt;br /&gt;
      s.executeUpdate(&amp;quot;CREATE TABLE package &amp;quot; + &amp;quot;(id INT, name VARCHAR(80))&amp;quot;);&lt;br /&gt;
      s.executeUpdate(&amp;quot;CREATE TABLE class &amp;quot; + &amp;quot;(id INT, packageId INT, name VARCHAR(48))&amp;quot;);&lt;br /&gt;
      s.executeUpdate(&amp;quot;CREATE TABLE member &amp;quot; + &amp;quot;(classId INT, name VARCHAR(48), isField BIT)&amp;quot;);&lt;br /&gt;
      // Prepare some statements that will be used to insert records into&lt;br /&gt;
      // these three tables.&lt;br /&gt;
      insertpackage = c.prepareStatement(&amp;quot;INSERT INTO package VALUES(?,?)&amp;quot;);&lt;br /&gt;
      insertclass = c.prepareStatement(&amp;quot;INSERT INTO class VALUES(?,?,?)&amp;quot;);&lt;br /&gt;
      insertmember = c.prepareStatement(&amp;quot;INSERT INTO member VALUES(?,?,?)&amp;quot;);&lt;br /&gt;
      // Now loop through the list of classes and use reflection&lt;br /&gt;
      // to store them all in the tables&lt;br /&gt;
      int numclasses = classnames.size();&lt;br /&gt;
      for (int i = 0; i &amp;lt; numclasses; i++) {&lt;br /&gt;
        try {&lt;br /&gt;
          storeClass((String) classnames.get(i));&lt;br /&gt;
        } catch (ClassNotFoundException e) {&lt;br /&gt;
          System.out.println(&amp;quot;WARNING: class not found: &amp;quot; + classnames.get(i) + &amp;quot;; SKIPPING&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      System.err.println(e);&lt;br /&gt;
      if (e instanceof SQLException)&lt;br /&gt;
        System.err.println(&amp;quot;SQLState: &amp;quot; + ((SQLException) e).getSQLState());&lt;br /&gt;
      System.err.println(&amp;quot;Usage: java MakeAPIDB &amp;quot; + &amp;quot;&amp;lt;classlistfile&amp;gt; &amp;lt;propfile&amp;gt;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    // When we&amp;quot;re done, close the connection to the database&lt;br /&gt;
    finally {&lt;br /&gt;
      try {&lt;br /&gt;
        c.close();&lt;br /&gt;
      } catch (Exception e) {&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * This hash table records the mapping between package names and package id.&lt;br /&gt;
   * This is the only one we need to store temporarily. The others are stored in&lt;br /&gt;
   * the db and don&amp;quot;t have to be looked up by this program&lt;br /&gt;
   */&lt;br /&gt;
  static Map package_to_id = new HashMap();&lt;br /&gt;
  // Counters for the package and class identifier columns&lt;br /&gt;
  static int packageId = 0, classId = 0;&lt;br /&gt;
  // Some prepared SQL statements for use in inserting&lt;br /&gt;
  // new values into the tables. Initialized in main() above.&lt;br /&gt;
  static PreparedStatement insertpackage, insertclass, insertmember;&lt;br /&gt;
  /**&lt;br /&gt;
   * Given a fully-qualified classname, this method stores the package name in&lt;br /&gt;
   * the package table (if it is not already there), stores the class name in&lt;br /&gt;
   * the class table, and then uses the Java Reflection API to look up all&lt;br /&gt;
   * methods and fields of the class, and stores those in the member table.&lt;br /&gt;
   */&lt;br /&gt;
  public static void storeClass(String name) throws SQLException, ClassNotFoundException {&lt;br /&gt;
    String packagename, classname;&lt;br /&gt;
    // Dynamically load the class.&lt;br /&gt;
    Class c = Class.forName(name);&lt;br /&gt;
    // Display output so the user knows that the program is progressing&lt;br /&gt;
    System.out.println(&amp;quot;Storing data for: &amp;quot; + name);&lt;br /&gt;
    // Figure out the packagename and the classname&lt;br /&gt;
    int pos = name.lastIndexOf(&amp;quot;.&amp;quot;);&lt;br /&gt;
    if (pos == -1) {&lt;br /&gt;
      packagename = &amp;quot;&amp;quot;;&lt;br /&gt;
      classname = name;&lt;br /&gt;
    } else {&lt;br /&gt;
      packagename = name.substring(0, pos);&lt;br /&gt;
      classname = name.substring(pos + 1);&lt;br /&gt;
    }&lt;br /&gt;
    // Figure out what the package id is. If there is one, then this&lt;br /&gt;
    // package has already been stored in the database. Otherwise, assign&lt;br /&gt;
    // an id, and store it and the packagename in the db.&lt;br /&gt;
    Integer pid;&lt;br /&gt;
    pid = (Integer) package_to_id.get(packagename); // Check hashtable&lt;br /&gt;
    if (pid == null) {&lt;br /&gt;
      pid = new Integer(++packageId); // Assign an id&lt;br /&gt;
      package_to_id.put(packagename, pid); // Remember it&lt;br /&gt;
      insertpackage.setInt(1, packageId); // Set statement args&lt;br /&gt;
      insertpackage.setString(2, packagename);&lt;br /&gt;
      insertpackage.executeUpdate(); // Insert into package db&lt;br /&gt;
    }&lt;br /&gt;
    // Now, store the classname in the class table of the database.&lt;br /&gt;
    // This record includes the package id, so that the class is linked to&lt;br /&gt;
    // the package that contains it. To store the class, we set arguments&lt;br /&gt;
    // to the PreparedStatement, then execute that statement&lt;br /&gt;
    insertclass.setInt(1, ++classId); // Set class identifier&lt;br /&gt;
    insertclass.setInt(2, pid.intValue()); // Set package identifier&lt;br /&gt;
    insertclass.setString(3, classname); // Set class name&lt;br /&gt;
    insertclass.executeUpdate(); // Insert the class record&lt;br /&gt;
    // Now, get a list of all non-private methods of the class, and&lt;br /&gt;
    // insert those into the &amp;quot;members&amp;quot; table of the database. Each&lt;br /&gt;
    // record includes the class id of the containing class, and also&lt;br /&gt;
    // a value that indicates that these are methods, not fields.&lt;br /&gt;
    Method[] methods = c.getDeclaredMethods(); // Get a list of methods&lt;br /&gt;
    for (int i = 0; i &amp;lt; methods.length; i++) { // For all non-private&lt;br /&gt;
      if (Modifier.isPrivate(methods[i].getModifiers()))&lt;br /&gt;
        continue;&lt;br /&gt;
      insertmember.setInt(1, classId); // Set the class id&lt;br /&gt;
      insertmember.setString(2, methods[i].getName()); // Set method name&lt;br /&gt;
      insertmember.setBoolean(3, false); // It is not a field&lt;br /&gt;
      insertmember.executeUpdate(); // Insert into db&lt;br /&gt;
    }&lt;br /&gt;
    // Do the same thing for the non-private fields of the class&lt;br /&gt;
    Field[] fields = c.getDeclaredFields(); // Get a list of fields&lt;br /&gt;
    for (int i = 0; i &amp;lt; fields.length; i++) { // For each non-private&lt;br /&gt;
      if (Modifier.isPrivate(fields[i].getModifiers()))&lt;br /&gt;
        continue;&lt;br /&gt;
      insertmember.setInt(1, classId); // Set the class id&lt;br /&gt;
      insertmember.setString(2, fields[i].getName()); // Set field name&lt;br /&gt;
      insertmember.setBoolean(3, true); // It is a field&lt;br /&gt;
      insertmember.executeUpdate(); // Insert the record&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Call the static method PressAnykey to keep to &amp;quot;DOS&amp;quot; window open. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
public class Main{&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    PressAnyKey();&lt;br /&gt;
  }&lt;br /&gt;
  public static void PressAnyKey() {&lt;br /&gt;
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;
    System.out.print(&amp;quot;Press any key...&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      input.readLine();&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create BufferedReader from FileReader and Read / display lines from file ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
class BufferedReaderDemo {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    FileReader fr = new FileReader(args[0]);&lt;br /&gt;
    // Create a buffered reader&lt;br /&gt;
    BufferedReader br = new BufferedReader(fr);&lt;br /&gt;
    // Read and display lines from file&lt;br /&gt;
    String s;&lt;br /&gt;
    while ((s = br.readLine()) != null)&lt;br /&gt;
      System.out.println(s);&lt;br /&gt;
    fr.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create BufferedReader from InputStreamReader and System.in, read console input ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
class Main {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    InputStreamReader isr = new InputStreamReader(System.in);&lt;br /&gt;
    BufferedReader br = new BufferedReader(isr);&lt;br /&gt;
    while (true) {&lt;br /&gt;
      System.out.print(&amp;quot;Radius? &amp;quot;);&lt;br /&gt;
      String str = br.readLine();&lt;br /&gt;
      double radius;&lt;br /&gt;
      try {&lt;br /&gt;
        radius = Double.valueOf(str).doubleValue();&lt;br /&gt;
      } catch (NumberFormatException nfe) {&lt;br /&gt;
        System.out.println(&amp;quot;Incorrect format!&amp;quot;);&lt;br /&gt;
        continue;&lt;br /&gt;
      }&lt;br /&gt;
      if (radius &amp;lt;= 0) {&lt;br /&gt;
        System.out.println(&amp;quot;Radius must be positive!&amp;quot;);&lt;br /&gt;
        continue;&lt;br /&gt;
      }&lt;br /&gt;
      System.out.println(&amp;quot;radius &amp;quot; + radius);&lt;br /&gt;
      return;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create BufferedReader from StringReader ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.BufferedWriter;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.FileWriter;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import java.io.StringReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;
    System.out.println(stdin.readLine());&lt;br /&gt;
    BufferedReader in = new BufferedReader(new FileReader(&amp;quot;Main.java&amp;quot;));&lt;br /&gt;
    String s, s2 = new String();&lt;br /&gt;
    while ((s = in.readLine()) != null)&lt;br /&gt;
      s2 += s + &amp;quot;\n&amp;quot;;&lt;br /&gt;
    in.close();&lt;br /&gt;
    StringReader in1 = new StringReader(s2);&lt;br /&gt;
    int c;&lt;br /&gt;
    while ((c = in1.read()) != -1)&lt;br /&gt;
      System.out.print((char) c);&lt;br /&gt;
    BufferedReader in2 = new BufferedReader(new StringReader(s2));&lt;br /&gt;
    PrintWriter out1 = new PrintWriter(new BufferedWriter(new FileWriter(&lt;br /&gt;
        &amp;quot;IODemo.out&amp;quot;)));&lt;br /&gt;
    int lineCount = 1;&lt;br /&gt;
    while ((s = in2.readLine()) != null)&lt;br /&gt;
      out1.println(lineCount++ + &amp;quot;: &amp;quot; + s);&lt;br /&gt;
    out1.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create BufferedReader from System.in ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.BufferedWriter;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
import java.io.OutputStreamWriter;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;
    String strLine = in.readLine();&lt;br /&gt;
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));&lt;br /&gt;
    out.write(strLine, 0, strLine.length());&lt;br /&gt;
    out.flush();&lt;br /&gt;
    in.close();&lt;br /&gt;
    out.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create BufferedReader from URL ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    URL url = new URL(&amp;quot;http://localhost:1776&amp;quot;);&lt;br /&gt;
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));&lt;br /&gt;
    String line;&lt;br /&gt;
    while ((line = in.readLine()) != null) {&lt;br /&gt;
      System.out.println(line);&lt;br /&gt;
    }&lt;br /&gt;
    in.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create BufferedReader out of FileReader ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.FileWriter;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
public class CopyLines {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    BufferedReader inputStream = null;&lt;br /&gt;
    PrintWriter outputStream = null;&lt;br /&gt;
    try {&lt;br /&gt;
      inputStream = new BufferedReader(new FileReader(&amp;quot;xanadu.txt&amp;quot;));&lt;br /&gt;
      outputStream = new PrintWriter(new FileWriter(&amp;quot;characteroutput.txt&amp;quot;));&lt;br /&gt;
      String l;&lt;br /&gt;
      while ((l = inputStream.readLine()) != null) {&lt;br /&gt;
        outputStream.println(l);&lt;br /&gt;
      }&lt;br /&gt;
    } finally {&lt;br /&gt;
      if (inputStream != null) {&lt;br /&gt;
        inputStream.close();&lt;br /&gt;
      }&lt;br /&gt;
      if (outputStream != null) {&lt;br /&gt;
        outputStream.close();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== List of lines in a file with BufferedReader ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import java.util.Random;&lt;br /&gt;
public class FileList {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final int assumedLineLength = 50;&lt;br /&gt;
    File file = new File(args[0]);&lt;br /&gt;
    List&amp;lt;String&amp;gt; fileList = new ArrayList&amp;lt;String&amp;gt;((int) (file.length() / assumedLineLength) * 2);&lt;br /&gt;
    BufferedReader reader = null;&lt;br /&gt;
    int lineCount = 0;&lt;br /&gt;
    try {&lt;br /&gt;
      reader = new BufferedReader(new FileReader(file));&lt;br /&gt;
      for (String line = reader.readLine(); line != null; line = reader.readLine()) {&lt;br /&gt;
        fileList.add(line);&lt;br /&gt;
        lineCount++;&lt;br /&gt;
      }&lt;br /&gt;
    } catch (IOException e) {&lt;br /&gt;
      System.err.format(&amp;quot;Could not read %s: %s%n&amp;quot;, file, e);&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    } finally {&lt;br /&gt;
      if (reader != null) {&lt;br /&gt;
        try {&lt;br /&gt;
          reader.close();&lt;br /&gt;
        } catch (IOException e) {&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    int repeats = Integer.parseInt(args[1]);&lt;br /&gt;
    Random random = new Random();&lt;br /&gt;
    for (int i = 0; i &amp;lt; repeats; i++) {&lt;br /&gt;
      System.out.format(&amp;quot;%d: %s%n&amp;quot;, i, fileList.get(random.nextInt(lineCount - 1)));&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Read a text file ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    File file = new File(&amp;quot;test.txt&amp;quot;);&lt;br /&gt;
    StringBuffer contents = new StringBuffer();&lt;br /&gt;
    BufferedReader reader = null;&lt;br /&gt;
    reader = new BufferedReader(new FileReader(file));&lt;br /&gt;
    String text = null;&lt;br /&gt;
    // repeat until all lines is read&lt;br /&gt;
    while ((text = reader.readLine()) != null) {&lt;br /&gt;
      contents.append(text).append(System.getProperty(&amp;quot;line.separator&amp;quot;));&lt;br /&gt;
    }&lt;br /&gt;
    reader.close();&lt;br /&gt;
    System.out.println(contents.toString());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Read content of a file ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    readTextFile(new File(&amp;quot;c:\\a.txt&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  public static String readTextFile(File filename) {&lt;br /&gt;
    try {&lt;br /&gt;
      BufferedReader br = new BufferedReader(new FileReader(filename));&lt;br /&gt;
      StringBuilder sb = new StringBuilder();&lt;br /&gt;
      String line = br.readLine();&lt;br /&gt;
      while (line != null) {&lt;br /&gt;
        sb.append(line + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        line = br.readLine();&lt;br /&gt;
      }&lt;br /&gt;
      br.close();&lt;br /&gt;
      return sb.toString();&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
      System.err.println(filename);&lt;br /&gt;
      System.err.println(e);&lt;br /&gt;
      return &amp;quot;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Read each line in a comma separated file into an array ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedReader br = new BufferedReader(new FileReader(&amp;quot;thefile.csv&amp;quot;));&lt;br /&gt;
    String line = null;&lt;br /&gt;
    while ((line = br.readLine()) != null) {&lt;br /&gt;
      String[] values = line.split(&amp;quot;,&amp;quot;);&lt;br /&gt;
      for (String str : values) {&lt;br /&gt;
        System.out.println(str);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    br.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Read from a file using a BufferedReader ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedReader bufferedReader = new BufferedReader(new FileReader(&amp;quot;yourFile.txt&amp;quot;));&lt;br /&gt;
    String line = null;&lt;br /&gt;
    while ((line = bufferedReader.readLine()) != null) {&lt;br /&gt;
      System.out.println(line);&lt;br /&gt;
    }&lt;br /&gt;
    bufferedReader.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading Text from a File ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    BufferedReader in = new BufferedReader(new FileReader(&amp;quot;infilename&amp;quot;));&lt;br /&gt;
    String str;&lt;br /&gt;
    while ((str = in.readLine()) != null) {&lt;br /&gt;
      System.out.println(str);&lt;br /&gt;
    }&lt;br /&gt;
    in.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Read lines of text from a file with the BufferedReader class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedReader br = new BufferedReader(new FileReader(&amp;quot;filename.txt&amp;quot;));&lt;br /&gt;
    String line = null;&lt;br /&gt;
    while ((line = br.readLine()) != null) {&lt;br /&gt;
      System.out.println(line);&lt;br /&gt;
    }&lt;br /&gt;
    br.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ReadLines: read file to list of strings ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
public class Utils {&lt;br /&gt;
  public static List&amp;lt;String&amp;gt; readLines(File file) throws Exception {&lt;br /&gt;
      if (!file.exists()) {&lt;br /&gt;
          return new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
      }&lt;br /&gt;
      BufferedReader reader = new BufferedReader(new FileReader(file));&lt;br /&gt;
      List&amp;lt;String&amp;gt; results = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
      String line = reader.readLine();&lt;br /&gt;
      while (line != null) {&lt;br /&gt;
          results.add(line);&lt;br /&gt;
          line = reader.readLine();&lt;br /&gt;
      }&lt;br /&gt;
      return results;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Tab filter: Convert tab to space characters ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.BufferedWriter;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.FileWriter;&lt;br /&gt;
class TabFilter {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    FileReader fr = new FileReader(args[0]);&lt;br /&gt;
    BufferedReader br = new BufferedReader(fr);&lt;br /&gt;
    FileWriter fw = new FileWriter(args[1]);&lt;br /&gt;
    BufferedWriter bw = new BufferedWriter(fw);&lt;br /&gt;
    // Convert tab to space characters&lt;br /&gt;
    String s;&lt;br /&gt;
    while ((s = br.readLine()) != null) {&lt;br /&gt;
      for (int i = 0; i &amp;lt; s.length(); i++) {&lt;br /&gt;
        char c = s.charAt(i);&lt;br /&gt;
        if (c == &amp;quot;\t&amp;quot;)&lt;br /&gt;
          c = &amp;quot; &amp;quot;;&lt;br /&gt;
        bw.write(c);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    bw.flush();&lt;br /&gt;
    fr.close();&lt;br /&gt;
    fw.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use BufferedReader to Read and process lines from console ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
class ReverseConsoleInput {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    InputStreamReader isr = new InputStreamReader(System.in);&lt;br /&gt;
    BufferedReader br = new BufferedReader(isr);&lt;br /&gt;
    // Read and process lines from console&lt;br /&gt;
    String s;&lt;br /&gt;
    while ((s = br.readLine()) != null) {&lt;br /&gt;
      StringBuffer sb = new StringBuffer(s);&lt;br /&gt;
      sb.reverse();&lt;br /&gt;
      System.out.println(sb);&lt;br /&gt;
    }&lt;br /&gt;
    isr.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use BufferedReader to read line by line ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    File file = new File(&amp;quot;.&amp;quot;);&lt;br /&gt;
    if (file.isDirectory()) {&lt;br /&gt;
      String[] files = file.list();&lt;br /&gt;
      for (int i = 0; i &amp;lt; files.length; i++)&lt;br /&gt;
        System.out.println(files[i]);&lt;br /&gt;
    } else {&lt;br /&gt;
      FileReader fr = new FileReader(file);&lt;br /&gt;
      BufferedReader in = new BufferedReader(fr);&lt;br /&gt;
      String line;&lt;br /&gt;
      while ((line = in.readLine()) != null)&lt;br /&gt;
        System.out.println(line);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using BufferedReader to read input number from user ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;
    String input = reader.readLine();&lt;br /&gt;
    double number = Double.parseDouble(input);&lt;br /&gt;
    System.out.println(input + &amp;quot;:&amp;quot; + Math.sqrt(number));&lt;br /&gt;
    reader.close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>