位置: 首頁 > 計算機 > 計算機二級

2016計算機二級考試Java語言程式設計輔導

2016-10-25 計算機二級

2016年3月計算機考試在3月26日-29日進行,為了幫助考生全面備戰,下面是本站小編為大家搜尋整理的`2016計算機二級考試Java語言程式設計輔導,供大家參考學習,預祝考生考試順利。

  練習一

如下的GreetingClient 是一個客戶端程式,該程式通過socket連線到服務器併發送一個請求,然後等待一個響應。

// 檔名

import .*;

import .*;

public class GreetingClient

{

public static void main(String [] args)

{

String serverName = args[0];

int port = eInt(args[1]);

try

{

tln("Connecting to " + serverName

+ " on port " + port);

Socket client = new Socket(serverName, port);

tln("Just connected to "

+ emoteSocketAddress());

OutputStream outToServer = utputStream();

DataOutputStream out =

new DataOutputStream(outToServer);

eUTF("Hello from "

+ ocalSocketAddress());

InputStream inFromServer = nputStream();

DataInputStream in =

new DataInputStream(inFromServer);

tln("Server says " + UTF());

e();

}catch(IOException e)

{

tStackTrace();

}

}

}

標籤:JAVA 程式設計 輔導 考試 計算機
2016-09-08
2017-12-15
2017-12-14
2015-09-24
2016-10-24
2017-12-07
2017-02-18
2016-10-24
2017-12-14
2016-09-13

Copyright ©2024 才華齋 All Rights Reserved.