簡體   English   中英

用Java編譯文本文件

[英]Compiling text files in java

我正在嘗試制作一個.txt文件的編譯器,並使用Java對其進行編譯。 我已經制作了一個,但是只能編譯.java文件。 我已經使用JavaCompiler類來做到這一點。

其次..要獲取文件,我使用了這個:

Class.forName("CLASS_NAME");

如何從項目文件夾中獲取外部文件?

問:
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");

只要這些文件夾都不是您的項目文件夾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM