Import java



import java.io.*;

/**

* An example of I/O streams in Java

*

* @author Professor David Bernstein

* @version 1.0

* @author Professor Elizabeth Adams

* @version 1.1

*/

public class WriterReaderExample

{

/**

* The entry point of the application

*

* @param args The command-line arguments

*/

public static void main(String[] args) throws IOException

{

BufferedReader myBufferedReader; // for input

PrintWriter myPrintWriter; // for output

String myStringData; // for data

//create BufferedReader object

myBufferedReader = new BufferedReader(new InputStreamReader(System.in));

myPrintWriter = new PrintWriter(System.out); // creates PrintWriter object

myPrintWriter.print("Enter a word: "); // prompts user

myPrintWriter.flush(); // empties the buffer

myStringData = myBufferedReader.readLine(); // gets the data

myPrintWriter.print("\nYou typed: " + myStringData + "\n"); // echoes the data

myPrintWriter.flush(); // flushes

}

}

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download