转[收集java的常用函数代码]
package net.java2000.tools;
/**
* Title: Java Bean 工具
* Description:
* Copyright: Copyright (c) 2001
* Company: JAVA世纪网
* @author 赵学庆
* @version 1.0
*/
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());
相关文档:
1.1. 概述
反射的概念是由Smith在1982年首次提出的,主要是指程序可以访问、检测和修改它本身状态或行为的一种能力。
反射本身并不是一个新概念,尽管计算机科学赋予了反射概念新的含义。在计算机科学领域,反射是指一类应用,它们能够自描述和自控制。也就是说,这类应用通过采用某种机制来实现对自己行为的描述(self-r ......
1.2.5.Method类:
Method代表某个类的一个方法,提供关于类或接口上单独某个方法的信息。所反映的方法可能是类方法或实例方法(包括抽象方法)。 这个类不难理解,它是用来封装反射类方法的一个类。
方法
描述
public String getName()
返回此 Method 对象表示的方法名称
public Object invoke(Object obj,Object... ......
1.3. 反射机制的功能
JAVA反射机制主要提供了以下功能:
1.在运行时判断任意一个对象所属的类
2.在运行时构造任意一个类的对象
3.在运行时判断任意一个类所具有的成员变量和方法(通过反射甚至可以调用private方 ......
一种是继承自Thread类.Thread 类是一个具体的类,即不是抽象类,该类封装了线程的行为。要创建一个线程,程序员必须创建一个从 Thread 类导出的新类。程序员通过覆盖 Thread 的 run() 函数来完成有用的工作。用户并不直接调用此函数;而是通过调用 Thread 的 start() 函数,该函数再调用 run()。
&nb ......
to create Menu @ JAVA & XML ....
first, to tell you how to do. just to fill the following Method provided by Activity.
public boolean onCreateOptionsMenu(Menu menu)
public boolean onOptionsItemSelected(MenuItem item)
public boolean onPrepareOptionsMenu(Menu menu)
3 method above is simple to ......