Is there a way (without buffering the entire Inputstream) to take the HttpServletRequest from the Java servlet and write it to a file using all the NIOs? Should I even try? Will it be faster reading from a regular java.io stream and writing to the java.nio channel, or do they really need to be pure NIO to see the advantage? Thanks.
EDIT:
So, I just did a quick and dirty test by reading a file from one disk and writing to another disk (so I actually test the code, not the disk).
Averages: InputStream -> OutputStream : 321 ms. FileChannel -> FileChannel : 3 ms. InputStream -> FileChannel : 600 ms.
I really got worse performance when trying to use hybrid java.io -> java.nio. Nio-> nio was faster than A LOT, but I was stuck in a Servlet InputStream.
java performance servlets nio
Gandalf
source share