客户端.java
try {
try {
br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
received = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("In-Cmd = " + received);
} finally {
try {
br.close();
} catch (Exception e) {}
}
服务器.java
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new OutputStreamWriter(connectionSocket.getOutputStream()));
System.out.println("Out-Cmd = STOP");
bw.write("stop");
bw.newLine();
} finally {
try {
bw.close();
} catch (Exception exp) {}
}
所以,我有这个 GUI,客户端可以将文件从本地硬盘上传到服务器,然后我们将复制文件并将它们存储在服务器中。
我可以将 BufferWriter 从客户端发送到服务器完全没有问题,但是当我想从服务器发送到客户端时,我总是收到null
难道我做错了什么?