Fix FileServer example
This commit is contained in:
parent
cfd514d099
commit
a52eafd7e8
@ -101,11 +101,12 @@ public class FileServer {
|
|||||||
ctx.write("Not a file: " + file + '\n');
|
ctx.write("Not a file: " + file + '\n');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageList<Object> out = MessageList.newInstance();
|
|
||||||
ctx.write(file + " " + file.length() + '\n');
|
ctx.write(file + " " + file.length() + '\n');
|
||||||
|
MessageList<Object> out = MessageList.newInstance();
|
||||||
FileRegion region = new DefaultFileRegion(new FileInputStream(file).getChannel(), 0, file.length());
|
FileRegion region = new DefaultFileRegion(new FileInputStream(file).getChannel(), 0, file.length());
|
||||||
out.add(region);
|
out.add(region);
|
||||||
out.add("\n");
|
out.add("\n");
|
||||||
|
ctx.write(out);
|
||||||
} else {
|
} else {
|
||||||
ctx.write("File not found: " + file + '\n');
|
ctx.write("File not found: " + file + '\n');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user