?? sslsocketclient.java
字號(hào):
package javasecurity;
import java.net.*;
import java.io.*;
import javax.net.ssl.*;
public class SSLSocketClient
{
public static void main(String[] args) throws Exception
{
try
{
// 建立SSL Socket連接的Factory
SSLSocketFactory factory =
(SSLSocketFactory) SSLSocketFactory.getDefault();
// 建立與localhost 2001端口的連接
SSLSocket socket =
(SSLSocket) factory.createSocket("localhost", 2001);
socket.startHandshake();
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter
(socket.getOutputStream())));
// 發(fā)送請(qǐng)求
out.println
("GET http://localhost:2001/index.html HTTP/1.1");
out.println();
out.flush();
if (out.checkError())
System.out.println(
"SSLSocketClient: java.io.PrintWriter error");
// 讀取回應(yīng)信息
BufferedReader in =
new BufferedReader(
new InputStreamReader(socket.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
out.close();
socket.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -