File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
src/test/java/com/fasterxml/jackson/core Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -624,4 +624,27 @@ protected int[] calcQuads(byte[] wordBytes) {
624
624
}
625
625
return result ;
626
626
}
627
+
628
+ protected byte [] readResource (String ref )
629
+ {
630
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream ();
631
+ final byte [] buf = new byte [4000 ];
632
+
633
+ InputStream in = getClass ().getResourceAsStream (ref );
634
+ if (in != null ) {
635
+ try {
636
+ int len ;
637
+ while ((len = in .read (buf )) > 0 ) {
638
+ bytes .write (buf , 0 , len );
639
+ }
640
+ in .close ();
641
+ } catch (IOException e ) {
642
+ throw new RuntimeException ("Failed to read resource '" +ref +"': " +e );
643
+ }
644
+ }
645
+ if (bytes .size () == 0 ) {
646
+ throw new IllegalArgumentException ("Failed to read resource '" +ref +"': empty resource?" );
647
+ }
648
+ return bytes .toByteArray ();
649
+ }
627
650
}
You can’t perform that action at this time.
0 commit comments