Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

ServletOutputStream output = response.getOutputStream();
output.write(byte[]);

What is the most effective way to write File to javax.servlet.ServletOutputStream?

EDIT:

won't this be more effective if the NIO was used?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
307 views
Welcome To Ask or Share your Answers For Others

1 Answer

IOUtils.copy(in, out);
out.flush();
//...........
out.close(); // depends on your application

Where in is the FileInputStream and out is the SocketOutputStream. IOUtils is a utility from Commons IO module in Apache Commons.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...