熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java語言的Socket類[2]

2022-06-13   來源: Java核心技術 

   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);

[]  []  []  


From:http://tw.wingwit.com/Article/program/Java/hx/201311/27217.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.