有人可以告诉我如何从下面的代码创建其他类吗? 我的老师不仅仅需要一个班级来完成这个任务,但是我在一个班级中完成了所有任务,所以如果可能的话,我需要帮助将其划分为多个班级。这是在Netbeans。创建多个类
package stringfinder;
/**
*
* @author Christopher, Martin, Rasmus
* @version 1.00
*/
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class StringFinder {
public void run()
{
int count = 0, countBuffer=0;
//Enter the filepath to your desired text file.
String filePath = "C:\\Users\\Christopher\\Dropbox\\Skole\\WordDistance\\words.txt";
BufferedReader br;
String line = "";
String inputSearch = "";
Scanner input = new Scanner(System.in);
try {
/**
* The first line welcomes the user to the application
* the second one tells the user to enter a keyword
* @param inputSearch is the keyword the user enters in the console.
*/
System.out.println("Welcome to Word Distance App");
System.out.print("Enter a keyword: ");
inputSearch = input.nextLine();
inputSearch = inputSearch.toLowerCase();
br = new BufferedReader(new FileReader(filePath));
try {
while((line = br.readLine()) != null)
{
String[] words = line.split(" ");
for (String word : words) {
if (word.equals(inputSearch)) {
count++;
countBuffer++;
}
}
if(countBuffer > 0)
{
countBuffer = 0;
}
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
/**
* The last two lines shows the how much the entered keyword differs from the actual word in words.txt
* @param count how many words were found
* @param inputSearch the previously entered keyword
*/
System.out.println("Distance 0. "+"("+count+" word)");
System.out.println(inputSearch);
}
}