0

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?

sepp2k
  • 363,768
  • 54
  • 674
  • 675
os.Kh
  • 45
  • 1
  • 10

1 Answers1

0

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.

Ben
  • 3,378
  • 30
  • 46