Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class CheckString {
- public static void main(String args[]) {
- try {
- System.out.print("Enter text: ");
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String text = br.readLine();
- System.out.print("Enter string to be searched: ");
- String pattern = br.readLine();
- if(text.contains(pattern)) {
- System.out.println(pattern + " found");
- } else {
- System.out.println(pattern + " not found");
- }
- } catch(IOException e) { e.printStackTrace(); }
- }
- }
Add Comment
Please, Sign In to add comment