[jcifs] Does jcifs use an internal buffer

Michael B Allen mba2000 at ioplex.com
Thu Jul 7 21:53:32 GMT 2005

Christoph Held said:
> Fujitsu EST is delivering jcifs with the Fujitsu Enabler product.
> I am wondering if jcifs uses an internal buffer.
> I have noticed that the read() function of SmbFileInputStream class is
> quite
> slow. Wrapped in a BufferedInputStream the read() function of
> BufferedInputStream is about 500 times faster. The conclusion is, that
> jcifs
> does not use an internal buffer (at least in our configuration).
> My questions are:
> 1. Is this conclusion correct?

Yes, SmbFileInputStream (like FileInputStream) is not buffered. The byte[]
buffer provided to read() is passed directly to the underlying socket
read(). If you're seeing poor performance you should try a larger byte[]
buffer or perhaps wrap it in a BufferedInputStream. It really depends on
the situation.

> 2. Should we recommend our customers, always to wrap the
> SmbFileInputStream in
> a BufferedInputStream?

I don't know about "always". If you use a sufficiently large byte[] buffer
(e.g. 8192) I don't think you should see any real performance difference.
If anything the direct read should actually be faster. With the
BufferedInputStream you're doing two System.arraycopys.

You could just add a little note in your docs like:

"Note: SmbFileInputStream and SmbFileOutputStream are not buffered. It may
be desireable to wrap these with BufferedInputStream and
BufferedOutputStream respectively depending on the situation."


More information about the jcifs mailing list