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
相关文档:
移位运算符
包括:
“>> 右移”;“<< 左移”;“>>> 无符号右移”
例子:
-5>>3=-1
1111 1111 1111 1111 1111 1111 1111 1011
1111 1111 1111 1111 1111 1111 1111 1111
其结果与 Math.floor((double)- ......
1. 简单工厂:
(1). 创建输出(Output)接口
package stone;
public interface Output {
public int MAX_COUNT =10; // 最多可打印多少条记录
public void show(); ......
// 简易JAVA获取网页有效邮箱地址 ---by 77
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class solo7 {
public static void main(String args[]){
  ......
var ProjectName = document.getElementById("<%=ProjectName.ClientID%>").innerText;
ProjectName = ProjectName.replace(/(^\s*)|(\s*$)/g, ""); // 相当于Trim()函数 ......
/**
* Copyright (c) 2010 IBOBO Corporation. All Rights Reserved.
*/
package com.ibm.util.dao.hib;
/**
* [Java Generics] get T.Class from <T>
*
* @author <a ......