All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.robolectric.shadows.ShadowIoUtils Maven / Gradle / Ivy

There is a newer version: 4.14
Show newest version
package org.robolectric.shadows;

import static java.nio.charset.StandardCharsets.UTF_8;

import android.os.Build;
import java.io.FileDescriptor;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import libcore.io.IoUtils;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;

@Implements(value = IoUtils.class, isInAndroidSdk = false)
public class ShadowIoUtils {

  @Implementation
  public static String readFileAsString(String absolutePath) throws IOException {
    return new String(Files.readAllBytes(Paths.get(absolutePath)), UTF_8);
  }

  @Implementation(minSdk = Build.VERSION_CODES.Q)
  protected static void setFdOwner(FileDescriptor fd, Object owner) {
    // ignore, fails in JVM environment
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy