为啥运行第二段代码总报错啊.求指点.好难过
public class Demo_02Client {
public static void main(String[] args) throws IOException {
Socket socket = new Socket(InetAddress.getLocalHost(), 8888);
OutputStream outputStream = socket.getOutputStream();
outputStream.write("你好!!!".getBytes());
outputStream.close();
socket.close();
System.out.println("传输完毕");
}
}
public class Demo_03Server2 {
public static void main(String[] args) throws IOException {
System.out.println("服务端启动......");
ServerSocket ss = new ServerSocket(8888);
while (true) {
Socket accept = ss.accept();
InputStream inputStream = accept.getInputStream();
byte[] b = new byte[100];
int len= inputStream.read(b);
String string = new String(b, 0, len);
System.out.println(string);
inputStream.close();
accept.close();
ss.close();
}
}
}
|
|