我试图在C:\
当前硬编码的目录中找到一个字符串。在这个C:\
目录中,我希望在根/和子目录中递归地找到输入的字符串(inputString),最后输出包含这些字符串的文件的名称。
我希望以上内容能澄清我最初的问题
我目前有评估.java:
import javax.swing.JFrame;
/* Notes: Event - user clicking button, moving mouse
* EventHandler - code that response to users action
*
*/
class assess {
public static void main(String args[]){
assesshelper assessment1 = new assesshelper();
assessment1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
assessment1.setSize(500,500); // set size of window
assessment1.setVisible(true);
}
}
和 assesshelper.java
import java.awt.FlowLayout; // orientation of screen
import javax.swing.JFrame; // JFrame all basic windows features (min/maximize), title
import javax.swing.JTextField; // Typing text
import javax.swing.JLabel; // output text / images
public class assesshelper extends JFrame {
private JLabel item1;
private JTextField theUrl;
public assesshelper(){ // anything within assesshelper is within window
super("Assess"); // title of window
setLayout(new FlowLayout()); // gives us default label
//item1
item1 = new JLabel("Welcome!");
add(item1); // add item1 to the screen
String setDir = "C:/";
JTextField inputString = new JTextField();
inputString.setText("ENTER DIR TO PROCESS");
/// BEGIN SEARCHING FOR INPUTTED STRING HERE WITHIN ROOT/SUBDIRECTORIES, OUTPUT FILE NAMES CONTAINING STRING
add(inputString);
}
}
如何递归搜索inputString
setDir 设置的目录中的值?
(这里是 Java 新手——请保持建设性)