集册 Java实例教程 将文本写入套接字

将文本写入套接字

欢马劈雪     最近更新时间:2020-01-02 10:19:05

443
将文本写入套接字

import java.io.BufferedWriter;

import java.io.IOException;

import java.io.OutputStreamWriter;

import java.net.Socket;/*来自 时 代 J a v a*/


public class Main {


  public static void main(String[] argv) {

    try {

      Socket socket = null;

      BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(

          socket.getOutputStream()));

      wr.write("aString");

      wr.flush();

    } catch (IOException e) {

    }

  }

}