JavaµÝ¹é
Java±éÀúÎļþ¼ÐµÄ2ÖÖ·½·¨£º
A.²»Ê¹Óõݹ飺
import java.io.File;
import java.util.LinkedList;
public class FileSystem {
public static void main(String[] args) {
long a = System.currentTimeMillis();
LinkedList list = new LinkedList();
File dir = new File("c:\\java\\");
File file[] = dir.listFiles();
for (int i = 0; i < file.length; i++) {
if (file[i].isDirectory())
list.add(file[i]);
else
System.out.println(file[i].getAbsolutePath());
}
File tmp;
while (!list.isEmpty()) {
tmp = list.removeFirst();
if (tmp.isDirectory()) {
file = tmp.listFiles();
if (file == null)
continue;
for (int i = 0; i < file.length; i++) {
if (file[i].isDirectory())
list.add(file[i]);
else
System.out.println(file[i].getAbsolutePath());
}
} else {
System.out.println(tmp.getAbsolutePath());
}
}
System.out.println(System.currentTimeMillis() - a);
}
}
B.ʹÓõݹ飺
import java.io.File;
import java.util.ArrayList;
public class FileSystem1 {
private static ArrayList filelist = new ArrayList();
public static void main(String[] args) {
long a = System.currentTimeMillis();
refreshFileList("c:\\java");
System.out.println(System.currentTimeMillis() - a);
}
public static void refreshFileList(String strPath) {
File dir = new File(strPath);
File[] files = dir.listFiles();
if (files == null)
return;
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
refreshFileList(files[i].getAbsolutePath());
} else {
Strin
Ïà¹ØÎĵµ£º
ÊÀ½çÉϲ¢Ã»ÓгÉΪ¸ßÊֵĽݾ¶£¬µ«Ò»Ð©»ù±¾ÔÔòÊÇ¿ÉÒÔ×ñѵġ£
1¡¢ÔúʵµÄ»ù´¡
Êý¾Ý½á¹¹¡¢ÀëÉ¢Êýѧ¡¢±àÒëÔÀí£¬ÕâЩÊÇËùÓмÆËã»ú¿ÆѧµÄ»ù´¡£¬Èç¹û²»ÕÆÎÕËüÃÇ£¬ºÜÄÑд³ö¸ßˮƽµÄ³ÌÐò¡£³ÌÐòÈËÈ˶¼»áд£¬µ«µ±Äã·¢ÏÖдµ½Ò»¶¨³Ì¶ÈºÜÄÑÔÙÌá¸ßµÄʱºò£¬¾ÍÓ¦¸ÃÏëÏëÊDz»ÊÇÒª»Ø¹ýÍ·À´Ñ§Ñ§ÕâЩ×î»ù±¾µÄÀíÂÛ¡£²»ÒªÒ»¿ªÊ¼¾ÍÈ ......
/*
* ººÅµËþ£¬´ÓµÚ1¸öÖù×Ó½èÖúµÚ2¸ùÖù×ÓÒƶ¯µ½µÚ3¸ù
*/
public class TowerOfHano {
private int totle;//×ܹ²ÅÌ×ÓÊýÄ¿
public TowerOfHano(int totle){
this.totle=totle;
}
&nb ......
Ò»¡¢Òý×Ó
»°ËµÊ®ÄêÇ°£¬ÓÐÒ»¸ö±¬·¢»§£¬Ëû¼ÒÓÐÈýÁ¾Æû³µ£¨Benz£¨±¼³Û£©¡¢Bmw£¨±¦Âí£©¡¢Audi£¨°ÂµÏ£©¿´À´ÕâÈ˱Ƚϰ®¹ú£¬Ã»ÓÐÈÕ±¾³µ£©£¬»¹¹ÍÁË˾»úΪËû¿ª³µ¡£²»¹ý£¬±¬·¢»§×ø³µÊ±×ÜÊÇÕâÑù£ºÉÏBenz³µºó¸ú˾»ú˵"¿ª±¼³Û³µ£¡"£¬×øÉÏBmwºóËû˵"¿ª±¦Âí³µ£¡"£¬×øÉÏAudiºóËû˵"¿ª°ÂµÏ³µ£¡"¡£ÄãÒ»¶¨Ëµ£ºÕâÈËÓв¡£¡Ö±½Ó˵¿ª³µ²»¾ÍÐÐÁË£¿£¡ ......