@Test @DisplayName("Loads resource from classpath") void getResource() { assertThat(Utility.getResource("log4j2.xml")).exists().canRead(); assertThat(Utility.getResource("log4j2-test.xml")).exists().canRead(); }
public static File getResource(String path) { ClassLoader[] classLoaders = {Thread .currentThread().getContextClassLoader(), Utility.class.getClassLoader(), ClassLoader.getSystemClassLoader()}; URL url = null; for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { url = classLoader.getResource(path); if (url != null) { break; } } } if (url == null) { throw new RuntimeException("Cannot find resource: " + path); } try { return new File(url.toURI().getSchemeSpecificPart()); } catch (Exception e) { throw new RuntimeException(e); } }
Utility { public static File getResource(String path) { ClassLoader[] classLoaders = {Thread .currentThread().getContextClassLoader(), Utility.class.getClassLoader(), ClassLoader.getSystemClassLoader()}; URL url = null; for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { url = classLoader.getResource(path); if (url != null) { break; } } } if (url == null) { throw new RuntimeException("Cannot find resource: " + path); } try { return new File(url.toURI().getSchemeSpecificPart()); } catch (Exception e) { throw new RuntimeException(e); } } }
Utility { public static File getResource(String path) { ClassLoader[] classLoaders = {Thread .currentThread().getContextClassLoader(), Utility.class.getClassLoader(), ClassLoader.getSystemClassLoader()}; URL url = null; for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { url = classLoader.getResource(path); if (url != null) { break; } } } if (url == null) { throw new RuntimeException("Cannot find resource: " + path); } try { return new File(url.toURI().getSchemeSpecificPart()); } catch (Exception e) { throw new RuntimeException(e); } }  }
Utility { public static File getResource(String path) { ClassLoader[] classLoaders = {Thread .currentThread().getContextClassLoader(), Utility.class.getClassLoader(), ClassLoader.getSystemClassLoader()}; URL url = null; for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { url = classLoader.getResource(path); if (url != null) { break; } } } if (url == null) { throw new RuntimeException("Cannot find resource: " + path); } try { return new File(url.toURI().getSchemeSpecificPart()); } catch (Exception e) { throw new RuntimeException(e); } }  static Pair<byte[], byte[]> extractHashAndSigFromFile(File file); static String getBalanceFileHash(String fileName); static RecordFile parseRecordFile(String filePath, Consumer<RecordItem> recordItemConsumer); static int readInt(DataInputStream dis, MessageDigest md); static byte[] readBytes(DataInputStream dis, int len, MessageDigest md); static Timestamp instantToTimestamp(Instant instant); static String accountIDToString(AccountID accountID); static Instant convertToInstant(Timestamp timestamp); static String printProtoMessage(GeneratedMessageV3 message); static String bytesToHex(byte[] bytes); static Long convertToNanos(long second, long nanos); static Long convertToNanosMax(long second, long nanos); static Long timeStampInNanos(Timestamp timestamp); static Long timestampInNanosMax(Timestamp timestamp); static boolean hashIsEmpty(String hash); static void archiveFile(File source, Path destinationRoot); static void purgeDirectory(Path path); static void ensureDirectory(Path path); static File getResource(String path); static final Instant getInstantFromFilename(String filename); static final long getTimestampFromFilename(String filename); static final String getStreamFilenameFromInstant(StreamType streamType, Instant instant); static final boolean isStreamFileAfterInstant(String filename, Instant instant); static @Nullable String protobufKeyToHexIfEd25519OrNull(@Nullable byte[] protobufKey); static TransactionID getTransactionId(AccountID payerAccountId); static boolean verifyHashChain(
            String actualPrevFileHash, String expectedPrevFileHash, Instant verifyHashAfter, String fileName); }
Utility { public static File getResource(String path) { ClassLoader[] classLoaders = {Thread .currentThread().getContextClassLoader(), Utility.class.getClassLoader(), ClassLoader.getSystemClassLoader()}; URL url = null; for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { url = classLoader.getResource(path); if (url != null) { break; } } } if (url == null) { throw new RuntimeException("Cannot find resource: " + path); } try { return new File(url.toURI().getSchemeSpecificPart()); } catch (Exception e) { throw new RuntimeException(e); } }  static Pair<byte[], byte[]> extractHashAndSigFromFile(File file); static String getBalanceFileHash(String fileName); static RecordFile parseRecordFile(String filePath, Consumer<RecordItem> recordItemConsumer); static int readInt(DataInputStream dis, MessageDigest md); static byte[] readBytes(DataInputStream dis, int len, MessageDigest md); static Timestamp instantToTimestamp(Instant instant); static String accountIDToString(AccountID accountID); static Instant convertToInstant(Timestamp timestamp); static String printProtoMessage(GeneratedMessageV3 message); static String bytesToHex(byte[] bytes); static Long convertToNanos(long second, long nanos); static Long convertToNanosMax(long second, long nanos); static Long timeStampInNanos(Timestamp timestamp); static Long timestampInNanosMax(Timestamp timestamp); static boolean hashIsEmpty(String hash); static void archiveFile(File source, Path destinationRoot); static void purgeDirectory(Path path); static void ensureDirectory(Path path); static File getResource(String path); static final Instant getInstantFromFilename(String filename); static final long getTimestampFromFilename(String filename); static final String getStreamFilenameFromInstant(StreamType streamType, Instant instant); static final boolean isStreamFileAfterInstant(String filename, Instant instant); static @Nullable String protobufKeyToHexIfEd25519OrNull(@Nullable byte[] protobufKey); static TransactionID getTransactionId(AccountID payerAccountId); static boolean verifyHashChain(
            String actualPrevFileHash, String expectedPrevFileHash, Instant verifyHashAfter, String fileName); static final Instant MAX_INSTANT_LONG; }