public static Buffer readResourceToBuffer(@NotNull Class<?> clazz, @NotNull String resource) {
        try {
            Buffer buffer = Buffer.buffer(0);

            try (InputStream in = clazz.getResourceAsStream(resource)) {
                int read;
                byte[] data = new byte[4096];
                while ((read = in.read(data, 0, data.length)) != -1) {
                    if (read == data.length) {
                        buffer.appendBytes(data);
                    } else {
                        byte[] slice = new byte[read];
                        System.arraycopy(data, 0, slice, 0, slice.length);
                        buffer.appendBytes(slice);
                    }
                }
            }

            return buffer;
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
public static Buffer readResourceToBuffer ( @ NotNull Class < ? > clazz , @ NotNull String resource ) { try { Buffer buffer = Buffer . buffer ( 0 ) ; try ( InputStream in = clazz . getResourceAsStream ( resource ) ) { int read ; byte [ ] data = new byte [ 4096 ] ; while ( ( read = in . read ( data , 0 , data . length ) ) != - 1 ) { if ( read == data . length ) { buffer . appendBytes ( data ) ; } else { byte [ ] slice = new byte [ read ] ; System . arraycopy ( data , 0 , slice , 0 , slice . length ) ; buffer . appendBytes ( slice ) ; } } } return buffer ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } }
Avoid using this method for constant reads, use it only for one time only reads from resources in the classpath