@@ -59,7 +59,7 @@ public final class TailOf implements Input {
5959 * @param bytes Number of last bytes to show from input
6060 */
6161 public TailOf (final Input inpt , final int bytes ) {
62- this (inpt , bytes , 16384 );
62+ this (inpt , bytes , 16_384 );
6363 }
6464
6565 /**
@@ -87,12 +87,13 @@ public InputStream stream() throws Exception {
8787 final byte [] buffer = new byte [this .max ];
8888 final byte [] response = new byte [this .count ];
8989 int num = 0 ;
90- final InputStream strm = this .input .stream ();
91- for (int read = strm .read (buffer ); read > 0 ; read = strm .read (buffer )) {
92- if (read < this .max && read < this .count ) {
93- num = this .copyPartial (buffer , response , num , read );
94- } else {
95- num = this .copy (buffer , response , read );
90+ try (InputStream strm = this .input .stream ()) {
91+ for (int read = strm .read (buffer ); read > 0 ; read = strm .read (buffer )) {
92+ if (read < this .max && read < this .count ) {
93+ num = this .copyPartial (buffer , response , num , read );
94+ } else {
95+ num = this .copy (buffer , response , read );
96+ }
9697 }
9798 }
9899 return new ByteArrayInputStream (response , 0 , num );
0 commit comments