?? tcpcliet_wangkj.java
字號:
package com.jk.net;
import java.net.*;
import java.io.*;
public class TcpCliet_wangkj {
public static void main(String[] args){
String address = "10.22.78.19";
int port = 8888;
Socket s = null;
InputStream is = null;
OutputStream os = null;
PrintWriter pw = null;
BufferedReader br = null;
try {
//1, 獲得socket
s = new Socket(address,port);
// 2,獲得輸出流
os = s.getOutputStream();
// 3,包裝輸出流
pw = new PrintWriter((new OutputStreamWriter(os,"UTF-8")),true);
//發送
pw.println("please give me your time now!!");
//獲得輸入流
is = s.getInputStream();
//包裝
br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
//7 接收
System.out.println(br.readLine());
//8 關閉
br.close();
is.close();
pw.close();
os.close();
s.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -