We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c799de6 commit b358467Copy full SHA for b358467
src/main/scala/com/github/kxbmap/netty/example/filetransfer/FileServer.scala
@@ -47,9 +47,11 @@ object FileServer extends App {
47
(file.exists(), file.isFile) match {
48
case (true, true) =>
49
ctx.write(s"$file ${file.length()}\n")
50
- val region = new DefaultFileRegion(new FileInputStream(file).getChannel, 0, file.length())
+ val fis = new FileInputStream(file)
51
+ val region = new DefaultFileRegion(fis.getChannel, 0, file.length())
52
ctx.write(region)
53
ctx.writeAndFlush("\n")
54
+ fis.close()
55
56
case (false, _) => ctx.writeAndFlush(s"File not found: $file\n")
57
case (_, false) => ctx.writeAndFlush(s"Not a file: $file\n")
0 commit comments