Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7791995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:03:51+00:00 2026-06-01T22:03:51+00:00

Here is my output: Four score and seven years ago…. However, the expected input

  • 0

Here is my output: “Four score and seven years ago….”

However, the expected input is: ” Four score and seven years ago…” (with a space between the quotation mark and ‘four'”.

How do I keep the leading whitespace? Here is my code so far.

public void checkDocument(Reader in, InputStream input, Writer out) throws IOException {
Scanner sc = new Scanner(input);
TokenScanner tok=new TokenScanner(in);
Token too;
Set<String> fileCor=new HashSet<String>();
while (tok.hasNext()){
    too=tok.next();
    System.out.println(too);
    if (too.isWord()){
        if (!(dict.isWord(too.toString()))){
            int n=1;
            fileCor=corr.getCorrections(too.toString());
            List<String> sortedOptions=new LinkedList<String>(fileCor);
            Collections.sort(sortedOptions);
            System.out.println("The word: "+too.toString()+" is not in the dictionary. Please enter the number corresponding with the appropriate action:");
            System.out.println("0: Ignore and continue");
            System.out.println("1: Replace with another word");
            for (int i=0;i<sortedOptions.size();i++){
                n=n+i+1;
                System.out.println((i+2)+": Replace with \""+sortedOptions.get(i)+"\"");
                }
            int choice=getNextInt(0, n, sc);
            if (choice==0){

            }
            else if (choice==1){
                out.write(getNextString(sc).trim());
            }
            else out.write(sortedOptions.get(choice-2).trim());

        }
        else out.write(too.toString().trim());

    }
    else {
        out.write(too.toString());
    }

}
System.out.println("Document completed");

 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:03:52+00:00Added an answer on June 1, 2026 at 10:03 pm

    Trim() Returns a copy of the string, with leading and trailing whitespace omitted.

    So, if you need only trailing spaces to be removed use the below regex expression.

    String newstr = str.replaceAll("\\s*$","");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is some dprofpp -I output, for almost the same program on different input
I am beginner to javascript and i am getting unexpected output here is the
So here's the output of inspect on a class: <Recurly::BillingInfo::CreditCard:0x1036a8a98 @prefix_options={}, @attributes={month=>1, last_four=>1, type=>bogus,
Alright, here is the output I get: arm-none-linux-gnueabi-ld --entry=main -dynamic-linker=/system/bin/linker -rpath-link=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -nostdlib -lstdc++
I've installed gtk2hs-buildtools with no problem, but here's the output when I try to
Here,I have some Doubt with the output. Why the Output is same ? int
Here is a js fiddle of my example output: http://jsfiddle.net/Hdzv8/ and below is the
Here is a simple program to output to a text file: #include <iostream> #include
Here is the complete install command to CPAN and the output: sudo perl -MCPAN
Here is my upsert code: UPDATE LastTicket SET LastTicketNumber=LastTicketNumber+1 OUTPUT INSERTED.LastTicketNumber WHERE CategoryId='1'; IF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.