JAVA常用操作语句 项目中的总结四
eclipse选一个变量后,这个类里的该变量不变色问题解决:
alt + shift + o
/**
* 写入日志
* filePath 日志文件的路径
* code 要写入日志文件的内容
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
FileWriter fw
=
new
FileWriter(tofile,
true
);
BufferedWriter bw
=
new
BufferedWriter(fw);
PrintWriter pw
=
new
PrintWriter(bw);
System.out.println(getDate()
+
"
:
"
+
code);
pw.println(getDate()
+
"
:
"
+
code);
pw.close();
bw.close();
fw.close();
return
true
;
}
catch
(IOException e) {
return
false
;
}
}
/**
* 判断是不是合法手机
* handset 手机号码
*/
public
static
boolean
isHandset(String handset) {
try
{
if
(
!
handset.substring(
0
,
1
).equals(
"
1
"
)) {
return
false
;
}
if
(handset
==
null
||
handset.length()
!=
11
) {
return
false
;
}
String check
=
"
^[0123456789]+$
"
;
Pattern regex
=
Pattern.compile(check);
Matcher matcher
=
regex.matcher(handset);
boolean
isMatched
=
matcher.matches();
if
(isMatched) {
return
true
;
}
else
{
return
false
;
}
}
catch
(RuntimeException e) {
return
false
;
}
}
ISBN(国际标准书号)的校验
Java code
public
class
Test {
public
static
void
main(String[] args) {
System.out.println(
"
9787302155638
"
+
ISBN.checkISBN(
"
9787302155638
"
));
System.out.println(
"
7564105607
"
+
ISBN.checkISBN(
"
7564105607
"
));
System.out.println(
"
730213880X
"
+
ISBN.checkISBN(
"
730213880X
"
));
System.out.println(
"
7302138800
"
+
ISBN.checkISBN(
"
7302138800
"
));
System.out.println(
"
9790000000000
"
+
ISBN.checkIS
相关文档:
作者: 佚名, 出处:IT专家网, 责任编辑: 谢妍妍, 2010-05-10 13:00
Java 把内存划分成两种:一种是栈内存,另一种是堆内存。在函数中定义的一些基本类型的变量和对象的引用变量都是在函数的栈内存中分配,当在一段代码块定义一个变量时,Java 就在栈中为这个变量分配内存空间,当超过变量的作用域后,Java 会自动释放掉 ......
JXL(Java Excel API)是一个用来动态读写Excel文件的开源框架,利用它可以在任何支持Java的操作系统上动态读写Excel文件。JXL的主页是:http://www.andykhan.com/jexcelapi/,可以在这里下载到它的最新的版本。
你可以分别通过如下命令
java -jar jxl.jar -xml test.xls
java -jar jxl.jar -cvs test.xls
以xml ......
jdk6和jdk5相比的新特性有:
1、instrumentation
在 Java SE 6 里面,instrumentation 包被赋予了更强大的功能:启动后的 instrument、本地代码 instrument,以及动态改变 classpath 等等。
2、Http有所增强
3、 Java 管理扩展(JMX) 架构及其框架,以及在 Java SE 5 中新引入的 JMX API -- java.l ......
var ProjectName = document.getElementById("<%=ProjectName.ClientID%>").innerText;
ProjectName = ProjectName.replace(/(^\s*)|(\s*$)/g, ""); // 相当于Trim()函数 ......
获得mysql和oracle链接的类
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectD ......