下面是文本文件上传的代码,关于流的关闭问题若干,请大家帮忙看看
客户端代码:
public class UploadClient {
public static void main(String[] args) throws IOException {
Socket s = new Socket("192.168.1.103", 10086);
BufferedReader bufr = new BufferedReader(new FileReader(
"UploadClient.txt"));
PrintWriter out = new PrintWriter(s.getOutputStream(), true);//这个流为什么不关闭了?什么时候关闭?
String line = null;
while ((line = bufr.readLine()) != null) {
out.println(line);
}