Find all string “the” in .txt file

后端 未结 5 2046
后悔当初
后悔当初 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:24

    It doesn't sound like the point of the exercise is to skill you up in regular expressions (I don't know it may be... but it seems a little basic for that), even though regexs would indeed be the real-world solution to things like this.

    My advice is to focus on the basics, use index of and substring to test the string. Think about how you could account for the naturally case sensitive nature of strings. Also, does your reader always get closed (i.e. is there a way bf.close() wouldn't be executed)?

提交回复
热议问题