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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:52:15+00:00 2026-06-15T22:52:15+00:00

I am not a native JAVA programmer. I am creating a client for an

  • 0

I am not a native JAVA programmer. I am creating a client for an web service API. The API basically requires an array argument.

I am parsing an XML file, creating records and then using this API to make a bulk INSERT.

The problem is that that this API can only insert 200 records at once that means my array can only have 200 records or less at the time of making the call.

Since I do not know how many records in advance, I store my records in an ArrayList and later convert it into an Array using .ToArray()

APIObject[] invoiceArray = invoiceObjectlist.toArray(new APIObject[invoiceDetailObjectlist.size()]);

Now because of the 200 limit problem posed by the API, I need to create these arrays in chunks of 200 till all records in the ArrayList have been inserted.

Right now am thinking that I can loop through the array list and maintain a counter. When the counter = 200, I can create a new array and insert all elements to that point by maintaining index pointers or I can push elements into a new array list for every 200 records and convert that into an array and perform the insert.

What would be a better elegant/efficient method to do this in JAVA?

Thanks.

  • 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-15T22:52:16+00:00Added an answer on June 15, 2026 at 10:52 pm
    List<APIObject[]> chunks = new ArrayList<APIObject[]>();
    for (int i = 0; i < bigList.size(); i += 200) {
      APIObject[] chunk = bigList.subList(i, Math.min(bigList.size(), i + 200))
        .toArray(new APIObject[200]);
      chunks.add(chunk);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy Java (not my native language) app that I'm trying to
First, i'm new at Java-programming and my native lang is not english, but still
WEB APP not native, no Objective-C This is so simple it hurts. <input type=date
All, I'm working on an HTML-based web app (i.e., not native app) targeted for
This is a WEB APP not a native app. Please no Objective-C NS commands.
I have to call a third-party Web service that frequently does not respond. I
I am not a web programmer, so please excuse my ignorance. When it comes
As a very novice Java programmer, I probably should not mess with that kind
(I am not a native speaker and might not be correct in terms of
Excuse me for my poor English, that is not my native language. I'm a

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.