23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 1.1. An xterm console on Unix<br />

Figure 1.2. A DOS shell console on Windows NT<br />

<strong>Java</strong> I/O<br />

Many common misconceptions about I/O occur because most programmers' first exposure to<br />

I/O is through the console. The console is convenient for quick hacks and toy examples<br />

commonly found in textbooks, and I will use it for that in this book, but it's really a very<br />

unusual source of input and destination for output, and good <strong>Java</strong> programs avoid it. It<br />

behaves almost, but not completely, unlike anything else you'd want to read from or write to.<br />

While consoles make convenient examples in programming texts like this one, they're a<br />

horrible user interface and really have little place in modern programs. Users are more<br />

comfortable with a well-defined graphical user interface. Furthermore, the console is<br />

unreliable across platforms. The Mac, for example, has no native console. Macintosh Runtime<br />

for <strong>Java</strong> 2 and earlier has a console window that works only for output, but not for input; that<br />

is, System.out works but System.in does not. [2] Figure 1.3 shows the Mac console window.<br />

2 Console input is supported in MRJ 2.1ea2 and presumably later releases.<br />

27

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

Saved successfully!

Ooh no, something went wrong!