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 9169343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:51:41+00:00 2026-06-17T15:51:41+00:00

I have about thousand lines of the type: <option value=1436>Some text <option value=36>Some text

  • 0

I have about thousand lines of the type:

<option value="1436">Some text
<option value="36">Some text

I want to store a fresh file, without <...> part in it.
The code I’m writing is:

try{
    FileInputStream fs= new FileInputStream(f);
    Scanner s= new Scanner(fs);
    while (s.hasNext()){
        String sentence=s.nextLine();
        int l=sentence.length();
        try{//printing P
            BufferedWriter bw = new BufferedWriter(new FileWriter("Ps.txt"));
            for (int i=0;i<l;i++){
                if (sentence.charAt(i)=='>'){
                    for (int j=i+1;j<l;j++)
                    bw.write(sentence.charAt(j));
                }
                bw.newLine();
            }
            bw.close();
        }   
        catch(Exception e){}
    }
}

However, it just storing 3-4 lines in the output file.

  • 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-17T15:51:42+00:00Added an answer on June 17, 2026 at 3:51 pm

    You are opening and closing the file inside your while loop.you’ll want to move it outside of the main loop, so you open the file once don’t close the file until the end.

    Thus, every iteration of the loop, you are overwriting the file, so the contents of the file will only be what was computed by the last iteration of the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some lines in a CSV file like this: 1000001234,Account Name,0,0,3,711.32,0,0,18,629.64,22,340.96,COD,20,000.00,Some string,Some string
I have written a C# program having some thousand lines and several threads. Execution
I have a text file with thousands of lines of text. Each line ends
So I have file with about thousand line that look like this: COADREAD ZNF271
I have a C# project and some code pages have few thousand lines of
I have inherited a Visual C++ project with about four thousand lines of code
I have about a thousand entries that all contain backslashes throughout the entry. Is
i have about 20 possible exception messages that i want thrown when an error
I find from reading perldoc perlvar, about a thousand lines in is help for
I have a file that has over 200 lines in this format: name old_id

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.