NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Browsing serially through a CSV file...

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
jon80



Joined: 05 May 2011
Posts: 29
Location: Malta

PostPosted: Sat Sep 10, 2011 8:43 am    Post subject: Browsing serially through a CSV file... Reply with quote

I am trying to create code that enables the user to browse serially through a CSV file, however, the following doesn't work, any idea why?

Code:

public void //<editor-fold defaultstate="collapsed" desc="Opens content from the catalogue file">
            openCatalogue (int skipRecords)
            //</editor-fold>
     throws IOException
    {

        int fieldNumber = 1 + skipRecords;
        while ((fieldNumber + skipRecords > 0) &&
                (fieldNumber <= FIELDS_PER_RECORD) &&
                (aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER) != null))
        {
           if (fieldNumber == (1 + skipRecords))
            {
                txtLocation.setText(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1));
            }
            else if (fieldNumber == 2 + skipRecords)
            {
               txtTitle.setText(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1));
            }
            else if (fieldNumber == 3 + skipRecords)
            {
               txtAuthor.setText((aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1)));
            }
            else if (fieldNumber == 4 + skipRecords)
            {
               txtPublisher.setText((aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1)));
            }
            else if (fieldNumber == 5 + skipRecords)
            {
                Integer musicType = Integer.parseInt(((aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1))));
                int musicTypeAsPrimitive = musicType.intValue();
                cboMusicType.setSelectedIndex(musicTypeAsPrimitive);

            }
            else if (fieldNumber == 6 + skipRecords)
            {

                final short SECONDS_TO_MINUTES = 60;
                Integer lengthInSeconds = Integer.parseInt(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1));
                txtLengthInMins.setText("" + (lengthInSeconds / SECONDS_TO_MINUTES));
                txtLengthInSeconds.setText("" + (lengthInSeconds % SECONDS_TO_MINUTES));
            }
            ++fieldNumber;
        } //end while

    }
...

private void btnPreviousActionPerformed(java.awt.event.ActionEvent evt) {
        try
        {
            this.openCatalogue(FIELDS_PER_RECORD * -1);
        }
        catch (IOException e)
        {
            System.out.println("DEBUG" + e.getMessage());
        }
    }

 private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {
        try
        {
            this.openCatalogue(FIELDS_PER_RECORD);
        }
        catch (IOException e)
        {
            System.out.println("DEBUG" + e.getMessage());
        }
    }



MusicCollection.rar
 Description:
source code

Download
 Filename:  MusicCollection.rar
 Filesize:  543.92 KB
 Downloaded:  49 Time(s)

Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo