javaµÃµ½Ò»¸ö°üµÄËùÓÐÀà
public static Class[] getClasses(String pckgname)
throws ClassNotFoundException {
ArrayList<Class> classes = new ArrayList<Class>();
// Get a File object for the package
File directory = null;
try {
ClassLoader cld = Thread.currentThread().getContextClassLoader();
if (cld == null)
throw new ClassNotFoundException("Can't get class loader.");
String path = '/' + pckgname.replace('.', '/');
URL resource = cld.getResource(path);
if (resource == null)
throw new ClassNotFoundException("No resource for " + path);
directory = new File(resource.getFile());
} catch (NullPointerException x) {
throw new ClassNotFoundException(pckgname + " (" + directory
+ ") does not appear to be a valid package a");
}
if (directory.exists()) {
// Get the list of the files contained in the package
String[] files = directory.list();
for (int i = 0; i < files.length; i++) {
// we are only interested in .class files
if (files[i].endsWith(".class")) {
// removes the .class extension
classes.add(Class.forName(pckgname + '.'
+ files[i].substring(0, files[i].length() - 6)));
}
}
} else
throw new ClassNotFoundException(pckgname
+ " does not appear to be a valid package b");
Class[] classesA = new Class[classes.size()];
classes.toArray(classesA);
return classesA;
}
Õâ¸ö·½·¨ÊÇ´ÓsunÂÛ̳ÉÏÕÒµ½µÄ£¬ËûÔÚeclipseµÄtomcat6.0»·
Ïà¹ØÎĵµ£º
from: http://mmblue.javaeye.com/blog/511915
package org.mmblue.common.util;
import java.util.List;
public class PageModel<T> {
// ......
¶ÓÁÐÊÇÉè¼Æ³ÌÐòÖг£ÓõÄÒ»ÖÖÊý¾Ý½á¹¹¡£ËüÀàËÆÈÕ³£Éú»îÖеÄÅŶÓÏÖÏ󣬲ÉÓÃÒ»ÖÖ±»³ÆÎª
“ÏȽøÏȳö”(FIFO)µÄ´æ´¢½á¹¹¡£Êý¾ÝÔªËØÖ»ÄÜ´Ó¶Óβ½øÈ룬´Ó¶ÓÊ×È¡³ö¡£ÔÚ¶ÓÁÐÖУ¬
Êý¾ÝÔªËØ¿ÉÒÔÈÎÒâÔö¼õ£¬µ«Êý¾ÝÔªËØµÄ´ÎÐò²»»á¸Ä±ä¡£Ã¿µ±ÓÐÊý¾ÝÔªËØ´Ó¶ÓÁÐÖб»È¡³ö£¬
ºóÃæµÄÊý¾ÝÔªËØÒÀ´ÎÏòÇ°ÒÆ¶¯Ò»Î»¡£ËùÒÔ£¬ÈκÎʱºò ......
±¾ÎÄÊÇÓÉJRÖ÷³Öд×÷µÄ¡¶J2SE½ø½×¡·Ò»ÊéµÄ²¿·ÖÕ½ÚÕûÀí¶ø³É£¬¡¶J2SE½ø½×¡·ÕýÔÚд×÷¡¢ÍêÉÆ½×¶Î¡£ÄúÔĶÁºó£¬ÓÐÈκν¨Òé¡¢ÅúÆÀ£¬ÇëºÍÎÒÁªÏµ£¬»òÔÚhttp://www.javaresearch.org/forum/thread.jsp?column=376&thread=7576' target='_blank' class='l2'>Õâ¶ùÁôÑÔ¡£¡¶J2SE½ø½×¡·Ð´×÷ÏîÄ¿×é¸ÐлÄúÔĶÁ±¾ÎÄ¡£
ÔÚµ±½ñÕ ......
package mylib.webxml;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/**
*
* @author jmp esp
* @version 1.0
*
&nbs ......
javaÖпÆÑ§¼ÆÊý·¨µÄ½â³ý
Êý¾Ý¹ý´ó»ò½Ó½üÓÚ0£¬java»á×Ô¶¯Ê¹ÓÿÆÑ§¼ÆÊý·¨ÏÔʾ
ҪʹµÃÊý¾ÝÒÔÕý³£µÄСÊýÏÔʾ¿ÉʹÓÃDecimalFormatÀࣺ
DecimalFormat format = new DecimalFormat("0.00000");
String value = format.format(doubleInstance);
......