File tree 1 file changed +19
-0
lines changed
smile/src/test/java/com/fasterxml/jackson/dataformat/smile
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -225,4 +225,23 @@ public String quote(String str) {
225
225
protected static String aposToQuotes (String str ) {
226
226
return str .replace ("'" , "\" " );
227
227
}
228
+
229
+ protected byte [] readResource (String ref )
230
+ {
231
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream ();
232
+ final byte [] buf = new byte [4000 ];
233
+
234
+ try (InputStream in = getClass ().getResourceAsStream (ref )) {
235
+ int len ;
236
+ while ((len = in .read (buf )) > 0 ) {
237
+ bytes .write (buf , 0 , len );
238
+ }
239
+ } catch (IOException e ) {
240
+ throw new RuntimeException ("Failed to read resource '" +ref +"': " +e );
241
+ }
242
+ if (bytes .size () == 0 ) {
243
+ throw new IllegalArgumentException ("Failed to read resource '" +ref +"': empty resource?" );
244
+ }
245
+ return bytes .toByteArray ();
246
+ }
228
247
}
You can’t perform that action at this time.
0 commit comments