当前位置: 技术问答>java相关
怎么用java.io.File类中的list方法?
来源: 互联网 发布时间:2015-02-09
本文导语: 用LIST方法能不能把目录中的文件名一次性全部显示出来? | /*===============================DirExplorer.java=========================================*/ import java.io.*; import java.awt.*; import java.awt.event.*; import java.u...
用LIST方法能不能把目录中的文件名一次性全部显示出来?
|
/*===============================DirExplorer.java=========================================*/
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
class DirExplorer
{
public static void main(String[] argv)
{
String path = "d:\";
Explorer(path);
System.out.println("The End!");
}
public static void Explorer(String p) //检测目录的递归算法
{
try{
boolean isAllFiles = true;
File path = new File(p);
System.out.println(path);
String[] list = path.list();
for(int i = 0; i
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
class DirExplorer
{
public static void main(String[] argv)
{
String path = "d:\";
Explorer(path);
System.out.println("The End!");
}
public static void Explorer(String p) //检测目录的递归算法
{
try{
boolean isAllFiles = true;
File path = new File(p);
System.out.println(path);
String[] list = path.list();
for(int i = 0; i