I'm trying to make a compiler that takes a .txt
file and compile it using java. I've already made one, but that compile only .java
files. I have used JavaCompiler
class to do that.
Secondly .. to get file I've used this:
Class.forName("CLASS_NAME");
How to get a file that is external from the project folder?
Q:
How to get a file that is external from the project folder?
A:
File aFile = new File("./../../folder1/folder2/test.jpg");
aFile = new File("C:/users/ABC/Desktop/test.png"); //no problems using / in Windows
aFile = new File("/home/ABC/test.pdf");
aFile = new File("D:/Folder");
aFile = new File(aFile, "file2.txt");
As long as none of these folders is your project-folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.