Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.util.Scanner;
- public class App{
- public static void main(String args[]) throws IOException {
- //Create Objects
- Scanner inputScanner = new Scanner(System.in);
- File file = new File("Options.txt");
- Scanner fileScanner = new Scanner(file);
- //Create Variables
- String browserPath = "";
- String browserExec = "";
- //Inform user
- System.out.println("Please type keyword: ");
- //Get user input
- String keyword = inputScanner.nextLine();
- keyword = keyword.replace(' ', '+');
- //Run main loop
- while(fileScanner.hasNextLine()) {
- String buffer = fileScanner.nextLine();
- if(buffer.matches("browserPath:")) {
- browserPath = fileScanner.nextLine();
- System.out.println("browserPath = " + browserPath);
- }
- if(buffer.matches("browserExec:")) {
- browserExec = fileScanner.nextLine();
- System.out.println("browserExec = " + browserExec);
- }
- if(buffer.matches("search:")){
- buffer = fileScanner.nextLine();
- Runtime rt = Runtime.getRuntime();
- rt.exec(browserPath + browserExec + " " + buffer + keyword);
- System.out.println("Searching: " + buffer);
- }
- }
- //Exit program
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement