private val in = new BufferedReader(new InputStreamReader(con.getInputStream()))
private val out = new PrintWriter(con.getOutputStream(), true)
try {
while (true) {
if (in.readLine() == null)
throw new IOException("connection reset by peer")
}
} catch {
case e: Exception =>
} finally {
// Is this necessary?
in.close()
out.close()
// Close socket
con.shutdownInput()
con.shutdownOutput()
con.close()
}
如果从套接字的输入或输出流创建任何 IO 流或读取器/写入器,是否需要在套接字关闭之前或之后关闭它们?