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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:53:10+00:00 2026-06-16T16:53:10+00:00

I have created a search and replace program using regular expression for large no

  • 0

I have created a search and replace program using regular expression for large no of files using eclipse ide.In this program I have given the name of directory in which search and replace to be performed(It may have sub directories also).For small no of files it runs smoothly but for directories having 1000 of files it hangs in between as does nothing(even after increasing the jvm memory size).
I have used BufferedReader to read each file line by line and used regex to match the pattern in the line and then replaced it with some other text.
Can any body suggest me the possible solution(Algorithms,Library,trick,hack) for it?

        BufferedReader br = new BufferedReader(new FileReader(fileName));
        BufferedWriter bw = new BufferedWriter(new FileWriter(changedFile));
        StringBuilder sb = new StringBuilder();
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            sb.append(line).append("\n");
        }
        br.close();
        sb.trimToSize();
        String code = sb.toString();
        code = code.replaceAll("System", "PrintWriter");
        bw.write(code);
        bw.flush();
        bw.close();
  • 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-16T16:53:11+00:00Added an answer on June 16, 2026 at 4:53 pm

    I suspect the write buffer in your OS is filling up and it must wait for the data to flush to disk unless you can determine the program really is hanging up due to a bug in it. Using the debugger is a simple way to test this or using jstack to take a stack trace.

    tell me exactly where is the problem.

    I suspect the problem is in the speed of your hard drive. If you have a HDD which has a seek time of 8 ms;

    • find the file for read 8 ms
    • read the file 4-12 ms
    • find the file for write 8 ms
    • write the file 4-12 ms
    • update filesystem journal 8 ms.

    The total time take is about 32 – 48 ms, which means you can update about 20 – 30 files per second.

    For <$50 you can buy a 32 GB SSD with an access time of 0.1 ms. You can buy double the size for not much more.

    • find the file for read 0.1 ms
    • read the file 0.1 ms
    • find the file for write 0.1 ms
    • write the file 0.1 ms
    • update filesystem journal 0.1 ms.

    The total time might be 0.5 ms allowing you to process up to 2000 files per second.

    The only reason it appears you can do more is that the OS caches reads and buffers writes, to a point. When these are exhaused (which they seem to be fairly quickly on Windows) you are limited by the speed of the drive.

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

Sidebar

Related Questions

I have to create a regular expression to match all wildcards in my search
I have created a search bar for my website, the user may search a
I have created a search feature for a site and in addition I made
I have created a keyword search in SQL that takes a list of keywords
I have created a Google Search function, however I would like to leave the
I have created an on the fly search field in Java Swing. I have
Good Morning, I have created an ASP.NET 3.5 webform that allows users to search
I just started programming in Basic4android. I have created 2 layouts. splash and search
I have a website, I've created with a 'Custom Search' functionality. I set it
first of all I'm using MySql. I have to create a advance search field

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.