㈠ 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。