使用SSLSocketFactory和SSLSocket创建回显客户端
import java.io.BufferedReader;//from 时 代 J a v a - nowjava.com import java.io.BufferedWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; public class Main { public static void main(String[] args) { try { SSLSocketFactory sslSocketFactory = /** from 时 代 J a v a - N o w J a v a . c o m**/ (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket("localhost", 9999); InputStreamReader inputStreamReader = new InputStreamReader(System.in); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); OutputStream outputStream = sslSocket.getOutputStream(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream); BufferedWriter bufferedwriter = new BufferedWriter(outputStreamWriter); String line = null;