PushCredentialResource.java 732 B

1234567891011121314151617181920212223
  1. package com.ruoyi.app.push;
  2. import org.springframework.core.io.ClassPathResource;
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.nio.file.Files;
  6. import java.nio.file.Path;
  7. /** Opens bundled push credentials while retaining absolute file path compatibility. */
  8. final class PushCredentialResource {
  9. private static final String CLASSPATH_PREFIX = "classpath:";
  10. private PushCredentialResource() {
  11. }
  12. static InputStream open(String location) throws IOException {
  13. if (location.startsWith(CLASSPATH_PREFIX)) {
  14. return new ClassPathResource(location.substring(CLASSPATH_PREFIX.length())).getInputStream();
  15. }
  16. return Files.newInputStream(Path.of(location));
  17. }
  18. }