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

The Archive Base Latest Questions

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

I’ve been bashing my head in on this problem for a few days now.

  • 0

I’ve been bashing my head in on this problem for a few days now. I’ve done my full share of Googling, and I’m hoping I can find someone here that is more experienced than I (not hard to find haha) that can decipher my problem.

Scenario: I developed a Java Applet that implements a Swing GUI. Background work: The Applet gathers records from a large “phone book” excel file (.csv) and stores them in a Map data structure. The phone book contains about 106,000 records, and on the 34,586th record, I get an ArrayIndexOutOfBoundsException that I cannot make sense of. The exception only occurs when I’m running the applet on my personal website. The applet runs perfectly fine with no errors while testing in my IDE (NetBeans) and running the .html file (the one that contains the applet) on my local machine. The output and exception that is thrown while running on my website is as follows (I cut most of the records to save space):

Java Console

Kary,Webber,2826 East 12th Ave.,Memphis,TN,38168,901-749-1834
Erinn,Rocha,2132 East Main Ave.,Memphis,TN,38168,865-414-5105
Gina,Lane,71 South First St. Apt. 11,Memphis,TN,38168,731-485-1129
Patsy,Hart,661 East 11th St.
java.lang.ArrayIndexOutOfBoundsException: 3
at Implementation.PersonnelDatabase.addRecordFromFields(PersonnelDatabase.java:192)
at Implementation.PersonnelDatabase.initDBFromFile(PersonnelDatabase.java:215)
at Implementation.PersonnelDatabase.processData(PersonnelDatabase.java:239)
at Implementation.PersonnelDatabaseApplet$2.doInBackground(PersonnelDatabaseApplet.java:78)
at Implementation.PersonnelDatabaseApplet$2.doInBackground(PersonnelDatabaseApplet.java:69)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

As you can see, on the 34,586th record (beginning with Patsy,Hart), it outputs midway through her address. The full record is as follows: Patsy,Hart,661 East 11th St. Apt. 195,Memphis,TN,38168,555-555-5555 .

Below are the sections of code that are most logically influenced by the exception.

Object tag in HTML file

<object type="application/x-java-applet" height="400" width="300">
  <param name="codebase" value="classes" />
  <param name="code" value="Implementation/PersonnelDatabaseApplet.class" />
  <param name="archive" value="PersonnelDatabase.jar" />
  Applet failed to run. No Java plug-in was found.
</object>

PersonnelDatabase class (processes background data):

/*
 * Create a new record using an appropriately ordered set of fields and add it to the data base
 */
public void addRecordFromFields(String[] fields)
{
    // Read record attributes in, one at a time
    Record thisRecord = new Record();
    thisRecord.setFirstName(fields[0]);
    thisRecord.setLastName(fields[1]);
    thisRecord.setAddress(fields[2]);
    thisRecord.setCity(fields[3]);
    thisRecord.setState(fields[4]);
    thisRecord.setZipCode(fields[5]);
    thisRecord.setPhoneNo(fields[6]);
    addRecord(thisRecord);
}

// O( n )
/**
 * Destroy the current data base and load new data from a file.
 * @param filename the file to use as a source
 * @throws IOException: Either file not found or IO error
 */
public void initDBFromFile(URL url) throws IOException
{
    // Open and read the file
    InputStream in = url.openStream();
    BufferedReader filein = new BufferedReader(new InputStreamReader(in));
    // Read record file, parse lines, and add records to data base
    String line = filein.readLine();
    while(line != null) {
        System.err.println(line);
        String[] fields = line.split(",");
        addRecordFromFields(fields);
        line = filein.readLine();
    }
    filein.close();
}

/**
 * Loads the default library and provides for interaction with the data
 * via the JPanel GUI inputs.
 * @param args
 * @throws IOException 
 */
public String processData(String input, int selection, URL url)
{
    //Create the main library object
    PersonnelDatabase dbiLib = new PersonnelDatabase();
    System.err.println(url);
    // Try to read the default library
    try
    {
        dbiLib.initDBFromFile(url);
    }
    catch (IOException e)
    {
        System.err.println("File IO Error");
        e.printStackTrace();
        System.exit(1);
    }
    // Queries can be simulated by typing into the console in Eclipse, and using Ctrl-d (Ctrl-z in Windows) when finished.
    // For example: "searchLastName,Smith" would print a list of all people with the last name of Smith.
    Iterable<Record> result = null;
    String[] fields = new String[2];
    if (input.contains(",")) {
        fields = input.split(",");
    }

    switch(selection) {
        case 0: result = dbiLib.searchByFirstName(input); break;
        case 1: result = dbiLib.searchByLastName(input); break;
        case 2: result = dbiLib.searchByFullName(fields[0].trim(), fields[1].trim()); break;
        case 3: result = dbiLib.searchByCity(input); break;
        case 4: result = dbiLib.searchByState(input); break;
        case 5: result = dbiLib.searchByCityState(fields[0].trim(), fields[1].trim()); break;
        case 6: result = dbiLib.searchByZip(input); break;
        case 7: result = dbiLib.searchByPhoneNumber(input); break;
        case 8: String[] newFields = new String[fields.length-1];
                System.arraycopy(fields, 1, newFields, 0, fields.length-1);
                dbiLib.addRecordFromFields(newFields);
                return "Record added successfully!\nEnter a query or add another record.";
        default: return "Invalid query.\nEnter another query or add a record.";
    }

PersonnelDatabaseApplet class (initializes GUI, gathers input, and displays output):

public void init() {
    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                initComponents();
            }
        });
    } catch (Exception e) {
        System.err.println("Creation of GUI did not successfully complete.");
    }
}

// Process inputs in the background.
SwingWorker worker = new SwingWorker<String, Void>() {
    @Override
    public String doInBackground() {
        URL url = null;
        try {
            url = new URL(getCodeBase(), fileToRead);
        }
        catch(MalformedURLException e){}
        personnelDatabase = new PersonnelDatabase();
        final String output = personnelDatabase.processData(input, selection, url);
        return output;
    }

    @Override
    public void done() {
        processingLabel.setVisible(true);
        try {
            textToDisplay = get(15, TimeUnit.SECONDS);
        } catch (InterruptedException ignore) {
            ignore.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            String why = null;
            Throwable cause = e.getCause();
            if(cause != null) {
                why = cause.getMessage();
                cause.printStackTrace();
            } else {
                why = e.getMessage();
                e.printStackTrace();
            }
            System.err.println("Error retrieving request: " + why);
            }
        if(worker.isDone() && textToDisplay != null) {
            processingLabel.setVisible(false);
            outputTextArea.setText(textToDisplay);
        }
    }
};

private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
selection = searchComboBox.getSelectedIndex();
input = valueTextField.getText();
processingLabel.setVisible(true);

worker.execute();

}

Link to the Applet on my personal website: http://www.ryan-taylor.me/Applied%20Maps/build/PersonnelDatabaseApplet.html

I’m fairly certain the error has nothing to do with the excel data itself as this program runs just fine in NetBeans and when running the html on my local machine. I’m guessing it has something to do with Swing (threads), but I’m not sure. I made changes to help with transferring data between Swing threads by making use of the SwingWorker, but I had no luck. I guess there’s always the possibility I missed something when implementing it.

I also thought about signing the jar, but the file that I’m processing is stored online – not a local machine – so I didn’t see a real need.

If anyone has any suggestions, I would greatly appreciate it!

  • 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-16T23:18:20+00:00Added an answer on June 16, 2026 at 11:18 pm

    It looks like something is causing the file to be truncated when you run the applet in a browser. My guess is that you are fetching the file from a web server, and either the server or the browser is silently enforcing some download limit. (Or may be the file got truncated when you uploaded it …)

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have been unable to fix a problem with Java Unicode and encoding. The
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms

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.