[英]Compiling text files in java
I'm trying to make a compiler that takes a .txt
file and compile it using java. 我正在尝试制作一个.txt
文件的编译器,并使用Java对其进行编译。 I've already made one, but that compile only .java
files. 我已经制作了一个,但是只能编译.java
文件。 I have used JavaCompiler
class to do that. 我已经使用JavaCompiler
类来做到这一点。
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: 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. 只要这些文件夹都不是您的项目文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.