java - Is TarArchiveInputStream buffered or unbuffered inputstream? -


is tararchiveinputstream buffered or unbuffered inputstream?

inputstream inputstream = new tararchiveinputstream(new gzipinputstream(new bufferedinputstream(new fileinputstream(file)))); 

does object of inputstream store whole entire file internally heap memory? or pointer file , stores nothing memory?

based on source code of commons-compress.jar ver 1.4,

what happens when create instance of tararchiveinputstream?

apart other initialization, important object gets created instance of tarbuffer object, internally has byte[] blockbuffer default size (default_rcdsize * 20) i..e, 512*20 = 10 kb.

this tarbuffer object performs reads operations , data blockbuffer underlying tar file readblock() method gets called internally invoke tararchiveinputstream.read(..)

does object of tararchiveinputstream store whole entire file internally heap memory?

no. in fact, in general, whenever call read method of inputstream if try data application buffer if stream buffered. if requested data present serves buffer. if not, signals os (through trap) read data os file cache/disk , copy buffer. (memory mapped files bit different copying not needed, not mix in our discussion).

this true in case of tararchiveinputstream well. call read method on tararchiveinputstream delegates inner inputstream , above same flow can visualized.

or pointer file , stores nothing memory?

while creating tararchiveinputstream pass inputstream argument , inputstream is, in fact, pointer (as far recollect, in inode number in *-nix os , points actual inode structure) file.

it store content memory explained before not entire file. how data read memory depends on size of byte[] passed while invoking read(...) method on tararchiveinputstream.

also, if helps, link used see how read entries using tararchiveinputstream.


Comments