Java examples for File Path IO:Scanner
prompts the user for a sentence and a string using Scanner
import java.util.Scanner; public class RemoveString { public static void main(String[] args) { Scanner scan = new Scanner(System.in); /*from w w w. jav a2 s . c om*/ String sentence; String text; System.out.print("Enter a sentence:"); sentence=scan.nextLine(); System.out.print("Enter a string:"); text=scan.nextLine(); System.out.print(sentence.replace(text, "")); scan.close(); } }