JAVA-2116: Split or move libraries-data-2 module (#9716)
* JAVA-2116: Move Java-R Integration to libraries-6 module * JAVA-2116: Move Guide to JMapper to libraries-data module
This commit is contained in:
33
libraries-6/src/main/java/com/baeldung/r/RUtils.java
Normal file
33
libraries-6/src/main/java/com/baeldung/r/RUtils.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.baeldung.r;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Utility class for loading the script.R content.
|
||||
*
|
||||
* @author Donato Rimenti
|
||||
*/
|
||||
public class RUtils {
|
||||
|
||||
/**
|
||||
* Loads the script.R and returns its content as a string.
|
||||
*
|
||||
* @return the script.R content as a string
|
||||
* @throws IOException if any error occurs
|
||||
* @throws URISyntaxException if any error occurs
|
||||
*/
|
||||
static String getMeanScriptContent() throws IOException, URISyntaxException {
|
||||
URI rScriptUri = RUtils.class.getClassLoader()
|
||||
.getResource("script.R")
|
||||
.toURI();
|
||||
Path inputScript = Paths.get(rScriptUri);
|
||||
return Files.lines(inputScript)
|
||||
.collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user