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

Create successful ePaper yourself

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

}<br />

public void run() {<br />

}<br />

try {<br />

byte[] buffer = new byte[256];<br />

while (true) {<br />

int bytesRead = theInput.read(buffer);<br />

if (bytesRead == -1) break;<br />

theOutput.write(buffer, 0, bytesRead);<br />

}<br />

}<br />

catch (<strong>IO</strong>Exception e) {System.err.println(e);}<br />

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

Here's a sample session where I used this program to connect to my ISP. After I logged out,<br />

the incoming line rang three times, which you also see:<br />

D:\JAVA\16>java PortTyper COM2<br />

at&f<br />

at&f<br />

OK<br />

atdt 321-1444<br />

atdt 321-1444<br />

CONNECT 9600/ARQ<br />

Welcome to Cloud 9 Internet!<br />

If you're already a user, please login below.<br />

To sign up for an account, type 'new', with no password.<br />

If you have trouble logging in, please call (914)696-4000.<br />

login: elharo<br />

elharo<br />

Password: **********<br />

Password: **********<br />

Last login: Thu May 28 18:26:14 from 168.100.253.71<br />

Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994<br />

The Regents of the University of California. All rights reserved.<br />

FreeBSD 2.2.6-RELEASE (EARL-GREY) #0: Tue May 19 10:39:36 EDT 1998<br />

You have new mail.<br />

> logout<br />

logo<br />

Connection closed.<br />

NO CARRIER<br />

RING<br />

RING<br />

RING<br />

This program would have been state of the art in 1978. These days, it's rather crude, and you'd<br />

have to do a lot of work to develop it further. For one thing, local echo mode should be turned<br />

439

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

Saved successfully!

Ooh no, something went wrong!