public class Client {
public static void main(String[] args){
Socket client = null;
OutputStream os = null;
BufferedWriter bw = null;
try {
//1.创建客户端对象
client = new Socket(InetAddress.getLocalHost(),10001);
//2.获取客户端对应的流对象
os = client.getOutputStream();
//3.包装流
bw = new BufferedWriter(new OutputStreamWriter(os));
//4.写出
bw.write("hello");
} catch (IOException e) {
e.printStackTrace();
} finally {
//5.关闭
try {
if (bw!=null){
bw.close();
}
if (os!=null){
os.close();
}
if (client!=null){
client.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
打了断点是bw这个write没有写出去数据,我看了一下代码没看出什么问题,希望各位大佬帮帮我