listjava.java

来自「网页分块的例子」· Java 代码 · 共 39 行

JAVA
39
字号
import java.io.*;

public class ListJava extends Object
{
     public static void main(String[] args)
     {

// Create a File instance for the current directory
          File currDir = new File(".");

// Get a filtered list of the .java files in the current directory
          String[] javaFiles = currDir.list(new JavaFilter());

// Print out the contents of the javaFiles array
          for (int i=0; i < javaFiles.length; i++) {
               System.out.println(javaFiles[i]);
          }
     }
}

// This class implements a filename filter that only allows
// files that end with .java

class JavaFilter extends Object implements FilenameFilter
{
     public JavaFilter()
     {
     }

     public boolean accept(File dir, String name)
     {

// Only return true for accept if the file ends with .java
          return name.endsWith(".class");

     }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?