File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
smile/src/test/java/com/fasterxml/jackson/dataformat/smile Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -255,4 +255,23 @@ protected static byte[] concat(byte[] ... chunks)
255
255
}
256
256
return bout .toByteArray ();
257
257
}
258
+
259
+ protected byte [] readResource (String ref )
260
+ {
261
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream ();
262
+ final byte [] buf = new byte [4000 ];
263
+
264
+ try (InputStream in = getClass ().getResourceAsStream (ref )) {
265
+ int len ;
266
+ while ((len = in .read (buf )) > 0 ) {
267
+ bytes .write (buf , 0 , len );
268
+ }
269
+ } catch (IOException e ) {
270
+ throw new RuntimeException ("Failed to read resource '" +ref +"': " +e );
271
+ }
272
+ if (bytes .size () == 0 ) {
273
+ throw new IllegalArgumentException ("Failed to read resource '" +ref +"': empty resource?" );
274
+ }
275
+ return bytes .toByteArray ();
276
+ }
258
277
}
You can’t perform that action at this time.
0 commit comments