23.11.2017 Views

java_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java<br />

Let's keep the above code in ReadConsole.<strong>java</strong> file and try to compile and execute it as<br />

shown in the following program. This program continues to raed and output the same<br />

character until we press 'q':<br />

$<strong>java</strong>c ReadConsole.<strong>java</strong><br />

$<strong>java</strong> ReadConsole<br />

Enter characters, 'q' to quit.<br />

1<br />

1<br />

e<br />

e<br />

q<br />

q<br />

Reading and Writing Files<br />

As described earlier, a stream can be defined as a sequence of data. The InputStream is<br />

used to read data from a source and the OutputStream is used for writing data to a<br />

destination.<br />

Here is a hierarchy of classes to deal with Input and Output streams.<br />

248

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!