public class JavaFileUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
JAR_EXTENSION
Extension of jar files.
|
static String |
JAVA_FILE_EXTENSION
Extension of Java files.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
cleanUnnecessaryFiles(Path exportDir)
Deletes unnecessary files from the given directory.
|
static void |
compileJavaFile(JavaCompiler compiler,
String javaFile)
Compiles the java file specified by the given
Path. |
static JarOutputStream |
createJar(Path directory,
String filename)
Creates a new empty jar.
|
static Object |
createNewInstanceFromClassLoader(String modelPath,
String simpleNameFormat,
URLClassLoader urlClassLoader)
Loads a class from a
URLClassLoader and creates new instance of that class. |
static URLClassLoader |
getUrlClassLoader(String modelPath,
ClassLoader classLoader)
Gets a
URLClassLoader used to retrieve an instance of class that contains the model. |
static JavaCompiler |
initCompiler()
Initializes the compiler using the ToolProvider API.
|
static boolean |
isJarFile(String filePath)
Verifies that the
filePath received by parameter is equals to the extension of
a Jar file. |
static boolean |
writeClassesToJar(Path exportDir,
JarOutputStream jar)
Writes the existing .class files on the directory into the jar file.
|
public static final String JAR_EXTENSION
public static final String JAVA_FILE_EXTENSION
public static URLClassLoader getUrlClassLoader(String modelPath, ClassLoader classLoader) throws com.feedzai.openml.provider.exception.ModelLoadingException
URLClassLoader used to retrieve an instance of class that contains the model.modelPath - Path of the binary with the model.URLClassLoader used to retrieve an instanece of the model.com.feedzai.openml.provider.exception.ModelLoadingException - If it cannot get the path of the model.public static Object createNewInstanceFromClassLoader(String modelPath, String simpleNameFormat, URLClassLoader urlClassLoader) throws com.feedzai.openml.provider.exception.ModelLoadingException
URLClassLoader and creates new instance of that class.modelPath - Path of the binary with the model.simpleNameFormat - Format of the class/package of the instance to create.urlClassLoader - The URLClassLoader used to retrieve an instance of the model.com.feedzai.openml.provider.exception.ModelLoadingException - If it cannot create the instance.public static boolean isJarFile(String filePath)
filePath received by parameter is equals to the extension of
a Jar file.filePath - The path of the file to be verified.public static JavaCompiler initCompiler()
public static void compileJavaFile(JavaCompiler compiler, String javaFile)
Path.javaFile - The Path of the java file.public static JarOutputStream createJar(Path directory, String filename) throws IOException
directory - The directory where to create the jar file.filename - The name of the jar file without the extension.new empty jar file.IOException - If any problem occurs accessing the file system.public static boolean writeClassesToJar(Path exportDir, JarOutputStream jar)
exportDir - The directory containing the .class filesjar - The jar to save the files to.public static boolean cleanUnnecessaryFiles(Path exportDir)
exportDir - The directory to clean.Copyright © 2018 Feedzai. All rights reserved.