shadows/framework/src/main/java/org/robolectric/shadows/ShadowLegacyAssetManager.java
private static Path getFileFromZip(Path path) {
    byte[] buffer = new byte[1024];
    try {
      Path outputDir = new TempDirectory("robolectric_assets").create("fromzip");
      try (InputStream zis = Fs.getInputStream(path)) {
        Path fileFromZip = outputDir.resolve(path.getFileName().toString());

        try (OutputStream fos = Files.newOutputStream(fileFromZip)) {
          int len;
          while ((len = zis.read(buffer)) > 0) {
            fos.write(buffer, 0, len);
          }
        }
        return fileFromZip;
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
private static Path getFileFromZip(Path path) {
    byte[] buffer = new byte[1024];
    try {
      Path outputDir = new TempDirectory("robolectric_assets").create("fromzip");
      try (InputStream zis = Fs.getInputStream(path)) {
        Path fileFromZip = outputDir.resolve(path.getFileName().toString());

        try (OutputStream fos = Files.newOutputStream(fileFromZip)) {
          int len;
          while ((len = zis.read(buffer)) > 0) {
            fos.write(buffer, 0, len);
          }
        }
        return fileFromZip;
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
private static Path getFileFromZip ( Path path ) { byte [ ] buffer = new byte [ 1024 ] ; try { Path outputDir = new TempDirectory ( "robolectric_assets" ) . create ( "fromzip" ) ; try ( InputStream zis = Fs . getInputStream ( path ) ) { Path fileFromZip = outputDir . resolve ( path . getFileName ( ) . toString ( ) ) ; try ( OutputStream fos = Files . newOutputStream ( fileFromZip ) ) { int len ; while ( ( len = zis . read ( buffer ) ) > 0 ) { fos . write ( buffer , 0 , len ) ; } } return fileFromZip ; } } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Extract an asset from a zipped up assets provided by the build system, this is required because
there is no way to get a FileDescriptor from a zip entry. This is a temporary measure for Bazel
which can be removed once binary resources are supported.
Extract an asset from a zipped up assets provided by the build system this is required because there is no way to get a FileDescriptor from a zip entry . This is a temporary measure for Bazel which can be removed once binary resources are supported .