Find all string “the” in .txt file

后端 未结 5 2052
后悔当初
后悔当初 2020-12-31 09:28

Here is my code:

// Import io so we can use file objects
import java.io.*;

public class SearchThe {
    public static void main(String args[]) {
        try         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 10:09

    You best should use Regular Expressions for this kind of search. As a easy/dirty workaround you could modify your stringSearch from

    String stringSearch = "the";
    

    to

    String stringSearch = " the ";
    

提交回复
热议问题