java中生成32位随机ID
在很多时候,我们需要自动生成永远不会重复的ID,因此我们会用到以下的代码来实现:
注意:需要加入两个apache的包,代码和包请从http://www.blogjava.net/afei0922/articles/129589.html 下载
package cn.com.cinda.rtx.state;
import org.apache.commons.id.Hex;
public class RandomCode {
public RandomCode() {
}
/** *//**
* @return String 生成32位的随机数作为id
*/
public String getCode() {
return new String(Hex.encodeHex(org.apache.commons.id.uuid.UUID
.randomUUID().getRawBytes()));
}
}
相关文档:
/**
* 把指定的内容写到指定路径的文本文件上
*
* @param path指定路径
* @param context 要写的内容
*/
public static void writeFile(String path, String context) {
// 从控制台输入内容写入文件
try {
FileWriter fw = new FileWriter(path, true);
PrintWriter pw = new Print ......
The Mean Opinion
Score (MOS) test is a well acccepted standard which is defined in the ITU-T
Rec.P.800.
The value of MOS
test is generated by letting large number of listeners to evaluate the quality
of the test sentences.
The test scores
are averaged to a mean score which range fro ......
1:应用程序不再需要使用 Class.forName() 显式地加载 JDBC 驱动程序。当前使用 Class.forName() 加载 JDBC 驱动程序的现有程序将在不作修改的情况下继续工作。
2:需要注意以下命令:
executeUpdate:是最基础的数据库的更新、插入和删除操作。效率低下。
executeQuery:是最基础的执行查询语句,同样 ......
说到GB2312和GBK就不得不提中文网页的编码。尽管很多新开发的Web系统和新上线的注重国际化的网站都开始使用UTF-8,仍有相当一部分的中文媒体坚持使用GB2312和GBK,例如新浪的页面。其中有两点很值得注意。
第一,页面中meta标签的部分,常常可以见到charset=GB2312这样的写法,很不幸的是,这个“cha ......
学习Java程序主要包含以下四个部分。
(1)编辑代码 edit code
(2)保存代码 save code
(3)编译代码 compiler code
(4)运行程序 run program
第一个程序文件HelloWorld.java
public class HelloWorld {
public static void main(String[] args){
......