-3
    public void readInput(Scanner sc) {

    while (sc.hasNext())

    {

    //check if we are in a tag to begin with

    String s = new String(sc.next());

    if (Pattern.matches("[\\p{Punct}\\p{IsPunctuation}]", s.substring( 
    s.length() - 1)) && !Pattern.matches("[]", s.substring( s.length() - 1)))

    //If word has punctuation at the end

    {

   Token ta = new Token(s.substring(0, s.length() - 1)); //Token of the word

   Token tb = new Token(s.substring(s.length() - 1)); //Token of Punctuation

   this.tokens.add(ta);

   this.tokens.add(tb);

   }

   else //if no punctuation add whole word

   {

   Token t = new Token(s);

   this.tokens.add(t);

  }

  if(s.compareTo("") == 0) {

  double startTime = System.nanoTime();//

  this.createWindows();

  this.printTextBlock();

  this.cleanup();

  double endTime = System.nanoTime();

   double duration = (endTime - startTime)/1000000000; //divide by 1000000 to 
   get 
    milliseconds.

  System.out.println("\n\n" + duration + " seconds runtime");

  }

  }

  sc.close();
ravthiru
  • 8,878
  • 2
  • 43
  • 52

1 Answers1

0

You need to simulate user input by passing scanner object to readInput Method something like this

String input = "Input";
InputStream in = new ByteArrayInputStream(input.getBytes());
Scanner scanner = new Scanner(in);
readInput(scanner);
ravthiru
  • 8,878
  • 2
  • 43
  • 52