Java的一些汇总
1.//property文件的读取
//com.test.message文件
package com.test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Test_Messages {
private static final String BUNDLE_NAME = "com.test.messages";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private Batch_Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}
2.Java批处理调用
Process process;
try {
process = Runtime.getRuntime().exec("D://test.bat");
BufferedReader read = new BufferedReader(new InputStreamReader(
process.getInputStream()));
String str = null;
while((str = read.readLine())!=null) {
System.err.println(str);
}
} catch(Exception e){
e.printStackTrace();
}
3.tomcat服务器端口更改方法:
由于tomcat服务器的缺省服务端口为8080,所以为了成功运行tomcat服务器一定要确保8080端口没有被其它软件占用。
如果已经被占用,我们需要改变tomcat服务器的服务端口,具体步骤如下:
打开tomcat服务器根路径下conf目录下的server.xml文件,找到如下配置标签:
<Connector port="8080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000" redirectPort="8443" />
将8080改为其它的端口,比如8088,这时客户端访问的路径应该为http://localhost:8088
相关文档:
1. 创建线程(继承Thread和实现runnable接口) class SubThread {
private class InnerThread extends Thread {
@Override
public void run() {
System.out.println(Thread.currentThread().getName());
super.run();
}
}
public Thread getThread() {
return new InnerThread();
}
}
......
public static void main(String[] args){
SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
String aimTime ="2010-02-03 17:30:00.000";
int count = 0;
Date aimDate = d ......
本文介绍Java Swing中的JTree模型,介绍如何创建、修改、遍历,设置树。参考Core Java2相关章节及其源代码。
Swing树使用人们所熟悉的文件夹和树叶图来显示分层的数据。树由节点组成,节点可以是文件夹,也可以是树叶。文件夹可以有子节点,除根节点之外的所有节点都只有一个父节点。空的文件夹与树叶的不同之处就在于它允 ......
BufferedReader:
Read text from a character-input
stream, buffering characters so as to provide for the
efficient reading of characters, arrays, and ......