public static void main(String[] args) throws UnknownHostException, IOException {
Socket socket = new Socket("127.0.0.1", 6666);
OutputStream fos = socket.getOutputStream();
byte[] bytes="你好啊啊啊啊".getBytes();
fos.write(bytes);
InputStream is = socket.getInputStream();
byte[] by = new byte[8];
is.read(by);
System.out.println(new String(by));
socket.close();
fos.close();
is.close(); |
|