㈠ java 如何減少編譯時間,是不需要的包不要 import 嗎
不是的,和包應該沒有太多的關系。應該和代碼的多少有關系.
比如說測試一個簡單的java類和測試一個struts2 +jpa+hibernate的項目編譯的時間就會大不相同了.
㈡ 為什麼java項目有的模塊很小但是編譯的時間很長
因為涉及到的業務比較多。
㈢ java 程序如何得到編譯時間 像C 里的 __DATE__ 一樣 printf("%s", __DATE__);
就我所知 貌似不能像C那麼簡單搞定
因為java最後都是編譯成.class文件 所以也許你可以通過找到對應的.class文件的最後修改時間來當作編譯時間
File file = new File("MyClass.class");
long time = file.lastModified();
僅供參考
㈣ java程序設計題
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test {
public static void main(String[] args) {
BufferedOutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(new File("d:/info.txt")));
String line = "第一行文本\n第二行文本";
out.write(line.getBytes());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream("d:/info.txt"));
StringBuffer buffer = new StringBuffer();
byte[] buff = new byte[in.available()];
while (in.read(buff) != -1) {
buffer.append(new String(buff));
}
System.out.println(buffer);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
in = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
㈤ 開發JAVA程序如何獲取系統編譯時間
import java.util.Date;
import java.text.SimpleDateFormat;
public class NowString {
public static void main(String[] args) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//設置日期格式
System.out.println(df.format(new Date()));// new Date()為獲取當前系統時間
}
}
㈥ java中import的作用
import的作用就是導入靜態成員,導入介面類型。
java中import的作用詳解:
一、java以這樣兩種方式導入包中的任何一個public的類和介面(只有public類和介面才能被導入)。
三、java.lang包是自動導入的。java編譯器會忽略這些冗餘導入聲明(rendant import declarations)。即使像這樣 import java.util.ArrayList; import java.util。