@@ -29,29 +29,31 @@ public byte[] readFile(String file) throws IOException {
2929 val b = files .get (file );
3030 return Arrays .copyOf (b , b .length );
3131 } else {
32- val s = TestInterpreter .class .getResourceAsStream ("/" + file );
33- if (s == null ) {
34- throw new FileNotFoundException ("Could not find resource " + file );
32+ try (val s = TestInterpreter .class .getResourceAsStream ("/" + file )) {
33+ if (s == null ) {
34+ throw new FileNotFoundException ("Could not find resource " + file );
35+ }
36+ val ret = new ByteArrayOutputStream ();
37+ val b = new byte [4096 ];
38+ var r = 0 ;
39+ while ((r = s .read (b )) > 0 ) {
40+ ret .write (b , 0 , r );
41+ }
42+ val bytes = ret .toByteArray ();
43+ files .put (file , bytes );
44+ return Arrays .copyOf (bytes , bytes .length );
3545 }
36- val ret = new ByteArrayOutputStream ();
37- val b = new byte [4096 ];
38- var r = 0 ;
39- while ((r = s .read (b )) > 0 ) {
40- ret .write (b , 0 , r );
41- }
42- val bytes = ret .toByteArray ();
43- files .put (file , bytes );
44- return Arrays .copyOf (bytes , bytes .length );
4546 }
4647 }
4748
4849 @ Override
49- public boolean writeFile (String file , byte [] data ) throws IOException {
50+ public boolean writeFile (String file , byte [] data ) {
5051 files .put (file , Arrays .copyOf (data , data .length ));
5152 return true ;
5253 }
5354 };
5455
56+ @ SuppressWarnings ("SameParameterValue" )
5557 private static byte [] readProgram (String path ) {
5658 val program = new ByteArrayOutputStream ();
5759 Assertions .assertDoesNotThrow (() -> {
0 commit comments