java

位置:IT落伍者 >> java >> 浏览文章

Java语言的Socket类[2]


发布日期:2022年04月12日
 
Java语言的Socket类[2]

isr = new InputStreamReader (sgetInputStream ());

// Create a buffered reader that chains to the input stream

// reader The buffered reader supplies a convenient method

// for reading entire lines of text

br = new BufferedReader (isr);

// Create a print writer that chains to the socket´s byte

// oriented output stream The print writer creates an

// intermediate output stream writer that converts

// characters sent to the socket to bytes The conversion

// is based on the platform´s default character set

pw = new PrintWriter (sgetOutputStream () true);

// Send the DATE command to the server

pwprintln (DATE);

// Obtain and print the current date/time

Systemoutprintln (brreadLine ());

// Send the PAUSE command to the server This allows several

// clients to start and verifies that the server is spawning

// multiple threads

pwprintln (PAUSE);

// Send the DOW command to the server

pwprintln (DOW);

// Obtain and print the current day of week

Systemoutprintln (brreadLine ());

// Send the DOM command to the server

pwprintln (DOM);

// Obtain and print the current day of month

Systemoutprintln (brreadLine ());

// Send the DOY command to the server

pwprintln (DOY);

[] [] []

               

上一篇:高级应用——Java动态的程序设计

下一篇:Java语言的Socket类[1]