Client.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) {}
}
Server.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,客户端可以将文件从本地硬盘上传到服务器,然后我们将文件复制并存储在服务器中。
我可以将ClientWriter从Client发送到Server没有任何问题,但是当我想从Server到Client时,我总是收到null
我做错了吗?