JAVA×Ö·û´®Àà
import java.util.*;
import java.util.regex.Pattern;
public class StrTools {
/**
* ·Ö¸î×Ö·û´®
*
* @param str String Ôʼ×Ö·û´®
* @param splitsign String ·Ö¸ô·û
* @return String[] ·Ö¸îºóµÄ×Ö·û´®Êý×é
*/
@SuppressWarnings("unchecked")
public static String[] split(String str, String splitsign) {
int index;
if (str == null || splitsign == null)
return null;
ArrayList al = new ArrayList();
while ((index = str.indexOf(splitsign)) != -1) {
al.add(str.substring(0, index));
str = str.substring(index + splitsign.length());
}
al.add(str);
return (String[]) al.toArray(new String[0]);
}
/**
* Ìæ»»×Ö·û´®
*
* @param from String Ôʼ×Ö·û´®
* @param to String Ä¿±ê×Ö·û´®
* @param source String ĸ×Ö·û´®
* @return String Ìæ»»ºóµÄ×Ö·û´®
*/
public static String replace(String from, String to, String source) {
if (source == null || from == null || to == null)
return null;
StringBuffer bf = new StringBuffer("");
int index = -1;
while ((index = source.indexOf(from)) != -1) {
bf.append(source.substring(0, index) + to);
source = source.substring(index + from.length());
index = source.indexOf(from);
}
bf.append(source);
return bf.toString();
}
/**
* Ìæ»»×Ö·û´®£¬ÄÜÄܹ»ÔÚHTMLÒ³ÃæÉÏÖ±½ÓÏÔʾ(Ìæ»»Ë«ÒýºÅºÍСÓÚºÅ)
*
* @param str String Ôʼ×Ö·û´®
* @return String Ìæ»»ºóµÄ×Ö·û´®
*/
public static String htmlencode(String str) {
if (str == null) {
return null;
}
return replace("\"", """, replace("<", "<", str));
}
/**
* Ìæ»»×Ö·û´®£¬½«±»±àÂëµÄת»»³ÉÔʼÂë£¨Ìæ»»³ÉË«ÒýºÅºÍСÓںţ©
*
* @param str String
* @return String
*/
public static String htmldecode(String str) {
if (str == null) {
return null;
}
return replace(""", "\"", replace("<", "<", str));
}
private static final String _BR = "<br/>"
Ïà¹ØÎĵµ£º
JAVAʵÏÖ
¡¡¡¡ÔÚJDKÖУ¬ÔÚjava.util.zip°üÖÐÒѾÄÚÖÃÁËZLIBµÄʵÏÖ£¬Ê¾Àý´úÂëÈçÏ£º
1//½âѹ
2 public String decompressData(String encdata) {
3 try {
4 ByteArrayOutputStream bos = new ByteArrayOutputStream();
5 InflaterOutputStream zos = new InflaterOutputStream(bos);
6 zo ......
javaÉè¼ÆÄ£Ê½Ñ§Ï°1££Singleton Pattern
¡¡¡¡Ç°Ð©Ìì°ÚŪjava£¬²Î¿¼Ò»Ð©×ÊÁÏдÁ˸öÊý¾Ý¿âÁ¬½Ó³Ø£¬¶ÔÀïÃæÖ»²úÉúÒ»¸öʵÀýµÄÄÇÖÖ×ö·¨Éî±íÅå·þ£¬½ñÌìÖÐÎçÓÖÌýµ½±ðÈËÔÚ˵Éè¼ÆÄ£Ê½£¬Êܲ»ÁËÁË£¬¾ÍÉÏÍøDownÁ˵ã×ÊÁÏÀ´¡£
¡¡¡¡Ò»À´¾Í¿´µ½ÁËSingletonģʽ£¬Ò»¿´£¬Ñ½£¬²»¾ÍÊÇÄǸöÁ¬½Ó³ØÀïÓõķ½·¨Ã´?!àÞ£¬ÔÀ´Èç´Ë¡£
¡¡¡¡Singleton Ê ......
ÔÚwindows×ÀÃæÉÏÓÒ»÷“ÎҵĵçÄÔ” —> “ÊôÐÔ” —> “¸ß¼¶” —> “»·¾³±äÁ¿”£¬Ôړϵͳ±äÁ¿”ÀïÎÒÃÇ¿ÉÒÔ¿´µ½ÏµÍ³µÄ¸÷¸ö»·¾³±äÁ¿µÄÖµ¡£Ë«»÷ij¸ö±äÁ¿Ãû¿ÉÒÔÐ޸ıäÁ¿Öµ£¬±äÁ¿ÖµÖ®¼äÓÓ;”¸ô¿ª¡£ÎÒÃÇ»¹¿ÉÒԓн¨”ÔÏÈÃ»Ó ......
ÏÈÌùÒ»¶Î
Java
»ù±¾½á¹¹
Java
½á¹¹°üÀ¨Ëĸö²»Í¬¶øÓÖÏà¹ØµÄ²¿·Ö£º
Java
ÓïÑÔ¡¢
class
Îļþ¸ñʽ¡¢Ó¦ÓóÌÐò½Ó
¿Ú¡¢ÐéÄâ»ú
ÆäÖУ¬ÐéÄâ»úµÄÖ÷ÒªÈÎÎñÊÇÔÚ³ÌÐòÔËÐÐÖÐÐèÒªµÄʱºòµ÷ÓÃ
class
Îļþ²¢Ö´ÐÐÆäÖеÄ×Ö½ÚÂë¡£Ò»¸ö
Java
Ó¦
ÓÃÓÐÁ½ÖÖ
class loader
£º
the system class loader
ºÍ
class loader objects
......
1¡¢Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orclΪÊý¾Ý¿âµÄSID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
2¡¢DB ......