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

  • Home
  • SEARCH
  • 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 8994391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:25:18+00:00 2026-06-15T23:25:18+00:00

I have created an application to process log files but am having some bottle

  • 0

I have created an application to process log files but am having some bottle neck when the amount of files = ~20

The issue comes from a particular method which takes on average a second or so to complete roughly and as you can imagime this isn’t practical when it needs to be done > 50 times

private String getIdFromLine(String line){
    String[] values = line.split("\t");
    String newLine = substringBetween(values[4], "Some String : ", "Value=");
     String[] split = newLine.split(" ");
     return split[1].substring(4, split[1].length());
}



private String substringBetween(String str, String open, String close) {
      if (str == null || open == null || close == null) {
          return null;
      }
      int start = str.indexOf(open);
      if (start != -1) {
          int end = str.indexOf(close, start + open.length());
          if (end != -1) {
              return str.substring(start + open.length(), end);
          }
      }
      return null;
  }

A line comes from the reading of a file which is very efficient so I don’t feel a need to post that code unless someone asks.

Is there anyway to improve perofmrance of this at all?

Thanks for your time

  • 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-15T23:25:19+00:00Added an answer on June 15, 2026 at 11:25 pm

    A few things are likely problematic:

    1. Whether or not you realized, you are using regular expressions. The argument to String.split() is a treated as a regex. Using String.indexOf() will almost certainly be a faster way to find the particular portion of the String that you want. As HRgiger points out, Guava’s splitter is a good choice because it does just that.

    2. You’re allocating a bunch of stuff you don’t need. Depending on how long your lines are, you could be creating a ton of extra Strings and String[]s that you don’t need (and the garbage collecting them). Another reason to avoid String.split().

    3. I also recommend using String.startsWith() and String.endsWith() rather that all of this stuff that you’re doing with the indexOf() if only for the fact that it’d be easier to read.

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

Sidebar

Related Questions

I have created an application using Adobe Flex. I took all the files from
I have created my own debugger application. It attaches to a process and creates
I have created an application that uses settings.settings to store some user specific settings
All, The application I have created works perfectly the first time around, but if
I have created a Java application that has 2 Jar files. Jar1 is used
I have a GUI application that process some data, it converts line of text
I have created application where i just need to access data form assets folder.
I have created an application in windows form. Once I submit the application, the
I have created Windows Application. In this, I have multiple tables in dataset, now
I have created an application that connect on a web-server and reads an xml

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.