Exemplo n.º 1
0
  @Override
  public File getResourceAsFile(String resource) throws IOException {
    String name = (new File(resource)).getName();
    if (name.isEmpty()) {
      throw new IOException("Invalid resource name: " + resource);
    }

    File extractedFile =
        new File(getTemporaryDirectory("resource_extraction_", Lifetimes.moeExecution()), name);
    makeDirsForFile(extractedFile);
    OutputStream os = Files.asByteSink(extractedFile).openStream();
    Resources.copy(SystemFileSystem.class.getResource(resource), os);
    os.close();
    return extractedFile;
  }
Exemplo n.º 2
0
 @Override
 public File getTemporaryDirectory(String prefix) {
   return getTemporaryDirectory(prefix, Lifetimes.currentTask());
 }